-
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
Soft deprecate custom 'pure' HoC in favor of 'React.memo' #57173
Changes from all commits
3265f61
67e3a46
7369cfa
2304b82
bbb678c
ad3c8a2
044154f
fc8f53a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,8 @@ _Related_ | |
|
||
### pure | ||
|
||
> **Deprecated** Use `memo` or `PureComponent` instead. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make it clear that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't find the issue, but I remember there was a talk of allowing imports from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we don't expose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only reason the
Mamaduka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Given a component returns the enhanced component augmented with a component only re-rendering when its props/state change | ||
|
||
### throttle | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ import { createHigherOrderComponent } from '../../utils/create-higher-order-comp | |
/** | ||
* Given a component returns the enhanced component augmented with a component | ||
* only re-rendering when its props/state change | ||
* | ||
* @deprecated Use `memo` or `PureComponent` instead. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
*/ | ||
const pure = createHigherOrderComponent( function < Props extends {} >( | ||
WrappedComponent: ComponentType< Props > | ||
|
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.
Hm, this feels super weird! Does this even work? :D
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 so 😅 there is even a Babel plugin that applies similar optimizations - https://babeljs.io/docs/babel-plugin-transform-react-constant-elements.html
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 was marked as an
error
by the neweslint-plugin-react-compiler
plugin - https://github.com/WordPress/gutenberg/actions/runs/9158471368/job/25176908344?pr=61788#step:5:86.