react-formatted-number-input
v2.0.0
Published
A higher order component for formatting values in input elements as numbers
Downloads
35
Readme
React formatted number input
A higher order component for formatting values in input elements as numbers
Install
$ npm install --save react-formatted-number-input
Usage
import React from 'react';
import { createFormattedNumberInput } from 'react-formatted-number-input';
const FancyInput = React.forwardRef((props, ref) => {
return <div><input ref={ref} {...props} /></div>;
});
const FormattedNumberInput = createFormattedNumberInput(FancyInput, { precision: 2 });
const Demo = () => {
const [value, setValue] = React.useState();
return <FormattedNumberInput value={value} onChange={setValue} />;
}
License
MIT © Jonathan Svenheden