-
Notifications
You must be signed in to change notification settings - Fork 839
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
[Emotion] Add HOC util for memoized styles + memoize EuiIcon
styles
#7544
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
993957f
Set up `withEuiStylesMemoizer` HOC for class components
cee-chen 8966f95
[EuiIcon] Update to use new memoized styles HOC
cee-chen edb9a42
[EuiIcon] DRY out internal style util with shared one
cee-chen 6b2adc0
[EuiIcon] Minor syntax cleanup
cee-chen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This results in the HoC component using the same display name as the wrapped component, which is confusing in React DevTools and may seem like improperly nested icons.
Could you please rename the HoC's
displayName
to match the recommendedHoCName(WrappedComponentName)
convention? In this case, that would be something likeWithEuiStylesMemoizer(${Component.displayName || Component.name || 'Component'})
. LMK what you think!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.
This is a copy of what we're already doing in
withEuiTheme
:eui/src/services/theme/hooks.tsx
Lines 67 to 84 in 829709e
I'm reluctant to change it for that reason, and also primarily because I believe it will massively fuck up snapshots (which was likely the original reason for Greg doing this weird shenanigans in the first place). I don't love it, but since we're already doing it and I don't really feel like going through a massively painful set of Kibana upgrades, I'd rather not change it.
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 get it, but that's a new HoC, so enzyme snapshots will be affected anyway, won't they? DOM snapshots should all be fine since they aren't aware of React vDOM structure
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.
No, they won't, because:
.displayName
is overridden to use the original componentdisplayName
withEuiTheme
withwithEuiStylesMemoizer
- that's the whole point of keeping the override the sameReact DevTools is not the same as Enzyme's shallow/mounted renderer and I believe this code was originally written with Enzyme in mind (bleh).
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.
aah gotcha, I missed the
withEuiTheme
diff part! I'm good leaving it as is then and hope enzyme snapshots will comply 🤣