-
Notifications
You must be signed in to change notification settings - Fork 842
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
[useEuiTheme] return a memoized object for performance #6165
[useEuiTheme] return a memoized object for performance #6165
Conversation
…nt, to help react optimize rendering performance
Preview documentation changes for this PR: https://eui.elastic.co/pr_6165/ |
1 similar comment
Preview documentation changes for this PR: https://eui.elastic.co/pr_6165/ |
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.
LGTM after removing the console.log
Thanks, Chandler!
theme={{ | ||
euiTheme, | ||
colorMode, | ||
modifications, | ||
}} |
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.
Ah good catch that this creates a new object on every render 🙇♂️
Co-authored-by: Greg Thompson <thompson.glowe@gmail.com>
Preview documentation changes for this PR: https://eui.elastic.co/pr_6165/ |
Summary
Fixes #6159
Threw a console.log in EuiIcon's render and verified any time its owner component rendered, the icon would unexpectedly re-render as well. Narrowed it down to a different
theme
prop coming in fromwithEuiTheme
on every render, and traced object creation to bothuseEuiTheme
andwithEuiTheme
.withEuiTheme
updated to forwarduseEuiTheme
's return value into the wrapped componentuseEuiTheme
updated with auseMemo
to keep the resulting object stableChecklist
- [ ] Checked in both light and dark modes- [ ] Checked in mobile- [ ] Checked in Chrome, Safari, Edge, and Firefox- [ ] Props have proper autodocs and playground toggles- [ ] Added documentation- [ ] Checked Code Sandbox works for any docs examples- [ ] Checked for accessibility including keyboard-only and screenreader modes- [ ] Updated the Figma library counterpart