-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Ensuring callbacks will execute after new state is ready. #990
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Are there any other components that should get this treatment?
Not that i'm aware of. i think it's the minimal required fix for now :) |
@iliran11 can you make this change in the |
@@ -645,9 +645,10 @@ export default class DayPickerRangeController extends React.Component { | |||
...newVisibleDays, | |||
...this.getModifiers(nextMonthVisibleDays), | |||
}, | |||
}, () => { | |||
onNextMonthClick(newCurrentMonth.clone()); | |||
}); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to delete this blank line
@majapw - done! ;) |
Sweet, thanks! |
onNextMonthClick
andonPrevMonthClick
callbacks were seemingly executing right after updating the state ofDayPickerSingleDateController.jsx
.However, It is not ensured and might cause some unexpected behavior caused by callbacks executing before the state update was completed (happened in my work project).
it is also a documented pitfall on react documentations.