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

Address DayPickerNavigation rerender #1363

Merged
merged 1 commit into from
Sep 19, 2018

Conversation

majapw
Copy link
Collaborator

@majapw majapw commented Sep 18, 2018

Fix for the DayPickerNavigation rerender discussed in #1297

Pretty simple fix involving moving around some arguments.

to: @ljharb @lencioni @AntiFish03

@majapw majapw added semver-patch: fixes/refactors/etc Anything that's not major or minor. performance labels Sep 18, 2018
@@ -446,7 +446,7 @@ class DayPicker extends BaseClass {
}
}

onPrevMonthClick(nextFocusedDate, e) {
onPrevMonthClick(e, nextFocusedDate) {
Copy link
Member

@ljharb ljharb Sep 18, 2018

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?

Copy link
Collaborator Author

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

@coveralls
Copy link

coveralls commented Sep 18, 2018

Coverage Status

Coverage increased (+0.06%) to 84.978% when pulling bffe704 on maja-address-daypickernav-rerender into f46195f on master.

@majapw majapw force-pushed the maja-address-daypickernav-rerender branch from ba73610 to de93e50 Compare September 18, 2018 20:32
@majapw
Copy link
Collaborator Author

majapw commented Sep 18, 2018

@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?

@majapw majapw force-pushed the maja-address-daypickernav-rerender branch from de93e50 to 051f280 Compare September 19, 2018 00:49
@majapw majapw force-pushed the maja-address-daypickernav-rerender branch from 051f280 to bffe704 Compare September 19, 2018 16:10
@majapw majapw merged commit 6e4ab7a into master Sep 19, 2018
@majapw majapw deleted the maja-address-daypickernav-rerender branch September 19, 2018 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance semver-patch: fixes/refactors/etc Anything that's not major or minor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants