-
-
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
Only update phrases object when the focusedInput actually changes. #448
Conversation
9dbbb05
to
99f9863
Compare
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.
Seems reasonable.
Test coverage? :-)
@ljharb I'm not entirely sure how to test this, especially given that it is in |
@majapw |
99f9863
to
b40b5d6
Compare
Added some tests! 🎉 |
}; | ||
|
||
describe('neither props.focusedInput nor props.phrases have changed', () => { | ||
it('state.phrases does not change', () => { |
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.
Did you mean to actually write a test here?
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 did. I just forgot. :P
b40b5d6
to
062db26
Compare
|
||
if (focusedInput !== this.props.focusedInput || phrases !== this.props.phrases) { | ||
// set the appropriate CalendarDay phrase based on focusedInput | ||
let chooseAvailableDate = phrases.chooseAvailableDate; |
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.
You could use destructuring here if you like.
Just curious, did you measure the performance impact of this change? |
@lencioni this change on its own will not have any performance impact due to the fact that each |
Realized this when I was prototyping some perf changes... but basically the modifiers object is not the only one that is changing (unnecessarily) on every render.
to: @moonboots @ljharb @airbnb/webinfra