Update LinkControl docs with advice to memoize value prop #54659
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.
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