-
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
Block: combine store subscriptions #56994
Conversation
Size Change: +1.62 kB (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
Flaky tests detected in 3e3d83a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7201187131
|
attributes, | ||
isValid, | ||
isSelected, | ||
} } |
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.
Is there a world where we could slowly deprecate these props :P. The clientId
should be enough for most filters :)
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.
Not sure :) I mean keeping them doesn't do much harm I think.
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 work.
It would be good to follow-up with some docs... to ease maintenance of these.
value={ { | ||
wrapperProps: restWrapperProps, | ||
isAligned, | ||
...context, | ||
} } |
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.
@ellatrix, can we add a comment here explaining why there's no need to memoize the BlockContext
value?
What?
Combines 3 store subscriptions into one. Reuses existing the context to pass down selected information from the block editor store.
The flow of data is now as follows:
BlockListBlockProvider
.wrapperProps
. We add this information also to the private context (as it was the case before this PR). Again we cannot use props because the next component (BlockEdit
) is also a filtered component.BlockListBlock
renders theBlockEdit
, which eventually callsuseBlockProps
, where we can now make use of this private context. Again, this is the same as before, nothing new here.The difference is that all information selecting is lifted up. This time it is created by
BlockListBlockProvider
, andBlockListBlock
adds information to it instead.Why?
First run: -8.4% for type, negligible for load
Second run: -11.7% for type
Third run: -12.1% for type
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast