-
-
Notifications
You must be signed in to change notification settings - Fork 743
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
When DayPickerInput get new props, it doesn't change its state #363
Comments
+1 |
Thinking about the use case here. Just resetting the state when the component receives new props doesn't work because the method it is always called when re-rendering the component. So we should add a condition there, like: componentWillReceiveProps(nextProps) {
if (nextProps.value !== this.state.value) {
this.setState(getStateFromProps(nextProps));
}
} however this will cause the overlay to flicker (hide/show) when passing a value from the parent component, e.g. in this example. A similar issue would appear if the entered value is empty hence I'd use if (nextProps.value && nextProps.value !== this.state.value) { but I'm not sure if this would cover the common use cases 🤔 |
+1 experiencing same issue |
Thanks people for the report, the bug should have been fixed in v5.5.2 |
Hi~ thanks for update~! I have a question about componentDidMount. thanks. |
@youreme are you talking about the |
@gpbl yes, constructor^^; Thanks for kindly information~ |
I had a bug where if you type something in input and prop value changes it does not update input value. class DayInput extends DayPickerInput { handleInputBlur(e) { this.setState({ typedValue: undefined }); this.inputBlurTimeout = setTimeout(() => { if (!this.overlayHasFocus) { this.hideDayPicker(); } }, 1); if (this.props.inputProps.onBlur) { e.persist(); this.props.inputProps.onBlur(e); } } } |
Hi,
When DayPickerInput gets nextProps, it doesn't change its states.
How about adding componentWillReceiveProps lifecycles?
After it mounted,
if it doesn't trigger any change events, the value state is different from value property.
DayPickerInput
The text was updated successfully, but these errors were encountered: