I am using react-number-format library to format input the user gives. But for some reason, when I save the data, the input is being saved as string and not number. Is this default behaviour? If yes, how can I change it to number such that the formatted string is saved as number with all characters(example $, comma etc) being removed?
This is how I am using it. npm package https://www.npmjs.com/package/react-number-format
<NumberFormat
thousandSeparator={true}
prefix={"$"}
decimalScale={2}
fixedDecimalScale
disabled={isDisabled}
/>
You can use
react-number-format'sonValueChangeprop to get thefloatValuewhich is of typenumber.It can be used like so:
From the docs:
See https://www.npmjs.com/package/react-number-format#values-object for more information.