Skip to content

Preserve selectedStartDate in state on props update#239

Open
wheywu wants to merge 1 commit intoonefinestay:masterfrom
wheywu:fix_selected_start_date
Open

Preserve selectedStartDate in state on props update#239
wheywu wants to merge 1 commit intoonefinestay:masterfrom
wheywu:fix_selected_start_date

Conversation

@wheywu
Copy link

@wheywu wheywu commented Nov 19, 2020

Currently, in componentWillReceiveProps, we always set selectedStartDate to be null. This can lead to buggy behavior when selectedStartDate was already set to something, as alluded to in these issues:

#224
#203

This issue will arise when the onSelectStart callback in the parent component does something that leads to changes in prop values passed into , which will lead to selectedStartDate in state to be reset. Keeping selectedStartDate whatever value it was in componentWillReceiveProps will fix this issue.

Currently, in `componentWillReceiveProps`, we always set `selectedStartDate` to be null. This can lead to buggy behavior when selectedStartDate was already set to something, as alluded to in these issues:

onefinestay#224
onefinestay#203

This issue will arise when the onSelectStart callback in the parent component does something that leads to changes in prop values passed into <DateRangePicker>, which will lead to `selectedStartDate` in state to be reset. Keeping selectedStartDate whatever value it was in componentWillReceiveProps will fix this issue.
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

Successfully merging this pull request may close these issues.

1 participant