-
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
Re-exported React.memo in packages/element/src/react.js #15385
Conversation
packages/element/src/react.js
Outdated
@@ -179,18 +185,18 @@ export { Suspense }; | |||
* @return {Array} The concatenated value. | |||
*/ | |||
export function concatChildren( ...childrenArguments ) { | |||
return childrenArguments.reduce( ( memo, children, i ) => { | |||
return childrenArguments.reduce( ( memoized, children, i ) => { |
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.
memo
was a poor choice of name to begin with (myself to blame), and was largely inherited from old Underscore.js documentation. There's a bit of inconsistency in how this argument is named elsewhere in the codebase, but "memoized" is not one of them, nor reflective of what the value is.
I might suggest result
instead.
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.
Indeed, result
is a better name for an accumulator. Thx.
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.
Looks good 👍
I'm assuming the prior build failure was an intermittent failure. I've restarted it.
All good now, but I'm not authorized to merge this :( |
I'll merge it 👍
It's a good question. I'm not the one to dole out permissions, but I think it may be good to raise this in next week's editor chat, both on the general point of prerequisites and on the specific point of having yourself granted access. I could raise it on your behalf if you're unable to attend. |
That would be amazing since I might have some job-related meetings at the same time. |
@@ -106,6 +107,11 @@ export { Fragment }; | |||
*/ | |||
export { isValidElement }; | |||
|
|||
/** | |||
* @see https://reactjs.org/docs/react-api.html#reactmemo |
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.
It should be included in CHANGELOG that we now expose memo
as well.
React.memo is a higher order component. It’s similar to React.PureComponent but for function components instead of classes.
Are we going to promote it over pure
HOC we offer in @wordpress/compose
package? Should we refactor pure
to use memo
internally? /cc @youknowriad
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 think there are differences where pure applies to any component and memo only to function components?
Description
Resolves: #15242
Types of changes
This PR is re-exporting React.js core
memo
method.Also refactored
concatChildren
internal memo to avoid conflicts with global one.Checklist: