react-use-locale-number-input
is a React hook that formats and parses number inputs based on the provided locale.
import React from "react";
import { useLocaleNumberInput } from "react-use-locale-number-input";
function ControlledInput() {
const [value, onChange] = React.useState("10000");
const {
value: displayValue,
handleBlur,
handleChange,
} = useLocaleNumberInput(value, "de-DE", onChange);
return (
<input onBlur={handleBlur} value={displayValue} onChange={handleChange} />
);
}
npm run test
See https://joswide.com for more details