-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite loop encountered when using onValueChange without setting valueIsNumericString prop #786
Comments
Actually, this is a valid case. So react-number-format automatically tries to identify what type of value is passed in the value prop. As both formatted string or non-formatted string can be passed, there can be case where the library can't differentiate between formatted value or non-formatted value. Currently this differentiation happens if we find any prefix or suffix on the string, but if prefix or suffix is not provided it can fail to identify in some case. Take an example of giving decimalSeparator as This can not be thrown as error as library doesn't have enough knowledge about how the values props is consumed or set. I think this is more of a documentation problem. I will mention the case on the doc. https://s-yadav.github.io/react-number-format/docs/props/#valueisnumericstring-boolean |
Actually there is some bug as well, auto guessing is not working out due to regression. Ideally, if the thousand separator is not |
The reported issue is fixed on v5.3.1. Also update the doc for https://s-yadav.github.io/react-number-format/docs/props/#valueisnumericstring-boolean |
Describe the issue and the actual behavior
I've encountered an issue when using the onValueChange callback with the
NumericFormat
component. Specifically, if I don't set thevalueIsNumericString
prop, my app enters an infinite loop. This seems to be directly related to how I set the valueDescribe the expected behavior
The NumericFormat component should handle the
onValueChange
callback seamlessly, even when thevalueIsNumericString
prop isn't set, without causing any infinite loops.If the
valueIsNumericString
prop is required, in that case, we need to inform the developer viaconsole.error
Provide a CodeSandbox link illustrating the issue
https://codesandbox.io/s/isnumericstring-demo-forked-jnkhk3?file=/src/App.js:0-645
The text was updated successfully, but these errors were encountered: