-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Update LinkControl docs with advice to memoize value prop #54659
Conversation
Flaky tests detected in 6fb2d75. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6406030158
|
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.
Thank you, @getdave!
What?
Documents the best practice to memoize the
value
prop passed to<LinkControl>
.Addresses #54603 (comment)
Props to @Mamaduka for the inspiration and the great work to fix this Issue in Core.
Why?
LinkControl is likely to be inside other compomnents which may re-render. Ifvalue
is not-memozied thenLinkControl
will then also have to re-render.As
LinkControl
maintains it's own internal state of any changes made by the user interacting with the control prior to submitting their changes. This is synchronised with thevalue
prop passed to the component.By memoizing the
value
we avoid this.This pattern is established in Core PRs:
How?
Add documentation.
Why don't you just remove the internal state?
If you ask this question please carefully read and evaluate the discussion in #51387 🙇
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast