Skip to content
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

Changing suffix does not change the value #62

Closed
retireupragu opened this issue May 23, 2017 · 1 comment
Closed

Changing suffix does not change the value #62

retireupragu opened this issue May 23, 2017 · 1 comment

Comments

@retireupragu
Copy link

When the value is changed, in componentWillReceiveProps the display value is calculated
like so

but the formatInput method uses the this.props instead of the newProps which is sent to the componentWillReceiveProps.

I was updating the value and suffix props, but the new suffix was not used, instead the older suffix gets used as it is referring to this.props instead of newProps.

The solution is to pass the props along to the formatInput and the other methods it invokes so this.props is never used from inside them. However once you remove the reference to this.props, these methods no longer need to be bound to the class, they could simply be functions outside of the class.

I am happy to do a PR, but need your direction on what you prefer, send props as an additional argument to formatInput, getSeparators, getNumberRegex, formatWithPattern

or

remove these functions out of the class and have them as pure functions which take in just the necessary input arguments

The suggested solution above fixes not only the suffix but also prefix and the whole list of props getting updated

@s-yadav
Copy link
Owner

s-yadav commented Jun 18, 2017

This been fixed on 2.0.0 alpha. closing this

@s-yadav s-yadav closed this as completed Jun 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants