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

Updating value props doesn't update input value #767

Open FabienCoutant opened 1 year ago

FabienCoutant commented 1 year ago

Describe the issue and the actual behavior

I have an input field where I can specify a maxValue and if user set value higher than the maxValue defined the state is set at the max one. The issue is that my state has correctly the maxValue set but not the input field value.

Describe the expected behavior

I expect the NumericFormat input value equal to the value props. The isAllowed block user to provided value whereas I would prefer to override it.

Provide a CodeSandbox link illustrating the issue

https://codesandbox.io/s/onvaluechange-demo-forked-4y4qhy?file=/src/App.js

Provide steps to reproduce this issue

The MAX defined is 10 000. Put any number above this max, you will see the state value block at 10000 but not the input value displayed.

Please check the browsers where the issue is seen

s-yadav commented 1 year ago

If isAllowed doesn't work for you. You can handle it like this for now.

https://github.com/s-yadav/react-number-format/issues/749#issuecomment-1529001614

FabienCoutant commented 1 year ago

Hey, thanks for your quick answer! :) I followed and tried the solution from #749 but it doesn't work as expected on my side 😢