react-numeric-input icon indicating copy to clipboard operation
react-numeric-input copied to clipboard

NumericInput value reset on setState

Open meeoh opened this issue 8 years ago • 2 comments

I'm using a numeric input value, changing its value, then later, calling a setState. This is causing the numericInput value to reset to its original value instead of repopulating. It seems this might be due to some sort of caching, is there a way to disable this?

meeoh avatar Oct 05 '17 20:10 meeoh

Had the same issue, I added value={this.state.numericInput} onChange={this.onNumericInputChange} to the NumericInput:

<NumericInput ref='numericInput' className="form-control" style={false} placeholder='Number here' onChange={this.onNumericInputChange} value={this.state.numericInput} />

And set value in the state(implementation of onNumericInputChange): onNumericInputChange(value) { this.setState({ numericInput: value }); }

It helped me.

AlexManoilo avatar Nov 27 '17 09:11 AlexManoilo

Can you provide an example so that I can try it?

vlad-ignatov avatar Jan 14 '18 15:01 vlad-ignatov