-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Format Library: Clean up 'Highlight' format components #62965
Conversation
onChange={ ( color ) => { | ||
onChange( | ||
setColors( value, name, colors, { [ property ]: color } ) | ||
); | ||
} } |
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 checked other usages of the ColorPalette
component; memoization isn't required.
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.
For clarity and my own edification, would you please elaborate on what you mean by "required?"
My interpretation is that you mean that memoizing this callback is unnecessary as ColorPalette
itself it not memoized. Is that accurate?
Thanks! 🙇🏻
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.
My interpretation is that you mean that memoizing this callback is unnecessary as ColorPalette itself it not memoized. Is that accurate?
Correct and the onChange
prop isn't a dependency for any side-effect ( useEffect
).
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -31 B (0%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
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.
Nice clean up
const colorIndicatorStyle = useMemo( | ||
() => | ||
fillComputedColors( | ||
contentRef.current, | ||
getActiveColors( value, name, colors ) | ||
), | ||
[ value, colors ] | ||
[ contentRef, value, colors ] |
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.
Note: The contentRef
is a ref object, but the ESLint plugin can't know this because it's passed as props. tl;dr; It's a false positive that we must fix, but it won't regress memo behavior.
onChange={ ( color ) => { | ||
onChange( | ||
setColors( value, name, colors, { [ property ]: color } ) | ||
); | ||
} } |
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.
For clarity and my own edification, would you please elaborate on what you mean by "required?"
My interpretation is that you mean that memoizing this callback is unnecessary as ColorPalette
itself it not memoized. Is that accurate?
Thanks! 🙇🏻
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 quickly tested the these changes on an iPhone simulator and Android emulator. I did not note any issues. Mentioning @geriux for awareness, just in case you have any concerns regarding these changes. 🙇🏻
What?
PR makes the following updates to the "Highlight" format components:
eslint-plugin-react-compiler
#61788.Why?
It's just a routine maintenance.
Testing Instructions
The feature also has test coverage.
Testing Instructions for Keyboard
Same.
Screenshots or screencast