I'm using react-number-format with react-hook-form Controller for a currency input.
The formState does not update correctly: isDirty and dirtyFields do not seem to update when editing the masked number input and then deleting the text.
I set the defaultValues to '' (empty string).
If I input a number, I can see that isDirty is true. But if I delete the input, and the value is '' (empty string) I still see isDirty is true - but the value is exactly the same as the defaultValue.
The issue is with line 54 in the file
masked-hook-form-inputs.js:onChange(values.floatValue);the value offloatValuecan beundefined, and this caused the problem.The solutionn Change line 54 to
onChange(isNaN(values.floatValue) ? '' : values.floatValue);Note that it's better to use
''(empty string) and notnull.