-
-
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
Address DayPickerNavigation rerender #1363
Conversation
src/components/DayPicker.jsx
Outdated
@@ -446,7 +446,7 @@ class DayPicker extends BaseClass { | |||
} | |||
} | |||
|
|||
onPrevMonthClick(nextFocusedDate, e) { | |||
onPrevMonthClick(e, nextFocusedDate) { |
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.
it's a pretty strong convention to have e
be last; why is this change needed?
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.
The motivation for this was because we were creating a new function in every render and causing unnecessary updates as a result. Flipping the order of arguments was a pretty simple solution, and was motivated by the fact that both arguments are occasionally omitted.
We could alternatively cache the function with the event as the second arg as well if you think it makes more sense @ljharb. It may make sense to have onNextMonthClick
take the event as an argument and call a function like transitionToNextMonth
that can also be called directly. 🤔 Actually, that may be less confusing in the long run
ba73610
to
de93e50
Compare
@ljharb I've split out the two cases that call the month transition into two functions. I think this approach makes more sense! Can you take another look? |
de93e50
to
051f280
Compare
051f280
to
bffe704
Compare
Fix for the DayPickerNavigation rerender discussed in #1297
Pretty simple fix involving moving around some arguments.
to: @ljharb @lencioni @AntiFish03