react-maskedinput is a React component designed to facilitate masked input fields, enabling developers to enforce specific input patterns for data like phone numbers, dates, or credit card numbers. It is built on top of the `inputmask-core` library for its core masking logic. The current stable version is 4.0.1, released in January 2018. Due to its age and the last release date, the project's release cadence is irregular and it appears to be largely unmaintained. Key features include support for custom format characters and controlled component behavior through the `value` prop. A significant note from the author indicates, "This project has never been used by its author, other than while making it," which might suggest limited real-world testing or ongoing support. Developers should consider its age and potential compatibility issues with modern React versions and ecosystems.
npm install react-maskedinputVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `MaskedInput` components into a React class component for various masked inputs like credit card numbers, expiry dates, and CCVs. It also shows how to define custom mask characters.
Ensure your React version meets the new `peerDependencies` (`^0.14.9 || ^15.3.0 || ^16.0.0`). If you were extending the component, ensure your code is updated to use modern React class components or functional components.
Update all instances where you define an input mask from `pattern="..."` to `mask="..."`.
Upgrade your project's React dependency to version 0.14 or newer.
Always provide an `onChange` handler directly to the `MaskedInput` component if you need to capture its value.
Exercise caution when using this package in production. Be prepared to fork, maintain, or find an alternative solution if issues arise.
Thoroughly test compatibility with your current React version and build setup. Consider exploring more actively maintained alternatives for critical applications or those requiring modern features.
Ensure your React project is on a version compatible with `React.Component` (React 0.14.9, 15.3.0, or 16.x) and that your build tools correctly transpile JavaScript classes.
Change the prop name from `pattern` to `mask` for your input masking definition. For example, `mask="1111"` instead of `pattern="1111"`.
Ensure your `onChange` handler correctly accesses `e.target.value` or `e.target.name` (as shown in the quickstart), understanding that the `e` object might not be a full `SyntheticEvent`.