s-yadav / react-number-format

React component to format numbers in an input or as a text.
MIT License
3.9k stars 410 forks source link

Cannot change value #778

Open rwb196884 opened 1 year ago

rwb196884 commented 1 year ago
const NumberFormatCustom = (props: NumberFormatProps) => {
  const { inputRef, ...other } = props;

  return (
    <NumberFormat
      {...other}
      readOnly={false}
      disabled={false}
      getInputRef={inputRef}
      thousandSeparator=","
      //decimalScale={props.decimalScale}
      fixedDecimalScale={true}
      placeholder={moneyPlaceholder}
      //isNumericString
      onValueChange={(values: NumberFormatValues) => {
        console.log(`NumberFormat.onValueChange ${JSON.stringify(values)}`);
      }}
    />
  );
};

A form element appears with a formatted value, but the value can't be changed. The onValueChange never fires, nor does the onChange that's hidden in ...other.

Can this be used for editing values or not?

s-yadav commented 1 year ago

Can you create a sandbox where it's not working?