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

setState in onSelectStart function is not working #224

Open
mpotnu opened this issue Oct 29, 2019 · 2 comments
Open

setState in onSelectStart function is not working #224

mpotnu opened this issue Oct 29, 2019 · 2 comments

Comments

@mpotnu
Copy link

mpotnu commented Oct 29, 2019

No description provided.

@itsmeganesh-cse-iiit
Copy link

Same issue here also, I am unable execute anything inside the onSelectStart method, If I try to execute anything apart from console log or alert then date range selection not working

@detrash08
Copy link

Hi, same issue. I'm trying to update a "start date" field content calling onSelectStart. It seems that when you change the DateRangePicker value field, passing an updated range, the component clears the current selection.
I've found this in DateRangePicker.componentWillReceiveProps:

const updatedState = {
    selectedStartDate: null,
    ...
}

The "selectedStartDate" state field seems to be used to determine how and what has to be highlighted.

wheywu added a commit to wheywu/react-daterange-picker that referenced this issue 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:
onefinestay#224
wheywu added a commit to wheywu/react-daterange-picker that referenced this issue 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:

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

No branches or pull requests

3 participants