Closed sentilesdal closed 3 years ago
You're right! Thanks. I'll accept the PR if you are keen... On Fri., 16 Dec. 2016 at 10:28, Matthew Brown notifications@github.com wrote:
getInitialState() { return { value: this.props.value || ''; }; },
should be
getInitialState() { let value = this.props.value || '';
if (this.props.type === 'number') { value = value || '0'; } return {value};
},
or some such equivalent. thanks for the good work though!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nkbt/react-debounce-input/issues/62, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKsoEBPDl6PkmNPXdvdvnivgpmdGbKQks5rIc0TgaJpZM4LOsER .
I recently made the change below on our own fork.
We don't test for type === 'number'
because we need the same functionality for text
inputs as well as number
.
@nkbt If you approve of my version, I don't mind making a PR.
getInitialState() {
return {
value: this.props.value || this.props.value === 0 ? this.props.value : ''
};
},
I think it may be better to do the other way around, plus cast to string like:
value: this.props.value === undefined ? '' : `${this.props.value}`
As far as I remember there is a code that relies on value being a string.
ping?
Closed by #125
should be
or some such equivalent. thanks for the good work though!