Skip to content

Conversation

@chandlerprall
Copy link
Contributor

@chandlerprall chandlerprall commented Aug 23, 2022

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 from withEuiTheme on every render, and traced object creation to both useEuiTheme and withEuiTheme.

  • withEuiTheme updated to forward useEuiTheme's return value into the wrapped component
  • useEuiTheme updated with a useMemo to keep the resulting object stable
  • added a unit test for regression

Checklist

- [ ] 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

  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
    - [ ] Updated the Figma library counterpart
  • A changelog entry exists and is marked appropriately

…nt, to help react optimize rendering performance
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6165/

1 similar comment
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6165/

Copy link
Contributor

@thompsongl thompsongl left a 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!

Comment on lines -57 to -61
theme={{
euiTheme,
colorMode,
modifications,
}}
Copy link
Contributor

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 🙇‍♂️

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6165/

@chandlerprall chandlerprall merged commit 6d44c2c into elastic:main Aug 24, 2022
@chandlerprall chandlerprall deleted the bug/6159-icon-rerendering branch August 24, 2022 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EuiIconClass re-rendering issue

3 participants