Search code examples
react-final-form

In Field from react-final-form how to convert input value to float only on blur?


If I use 'parse', then the user can not enter the decimal separator.

Because "9." is parsed as 9 and instantly replaces the input text.

Sandbox: https://codesandbox.io/s/xmj92nnpo


Solution

  • I end up with my own StatefulInput component, with 'editing' flag in the internal state. And I call Field's 'onChange' event handler only on blur.

    https://codesandbox.io/s/2zpn29zzjj