-
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
Block edit: avoid memoized block context in favour of useSelect #29333
Conversation
b28f4a9
to
e20310d
Compare
Size Change: -15 B (0%) Total Size: 1.4 MB
ℹ️ View Unchanged
|
e20310d
to
5c5e387
Compare
5c5e387
to
3ddbaef
Compare
I run into this PR when investigating failing tests in #28456. I have some concerns regarding the changes proposed in this PR. It feels like the |
Cc @youknowriad I'll investigate the performance problem. Generally we should avoid passing data down that can be derived from something else like the client ID. Where do we draw the line? You could pass lots of data like the block type, other selection info... through memoized context. Our data API should be a superior way to retrieve and memoize data only in places where it's needed. |
Worth noting that #29309 deprecates the hook in favour of a new one, which restores performance to previous levels. The PR is blocked by mobile though, which is why it was done it multiple pieces. |
I believe the temporary performance hit is due to some extra |
I agree that the performance gap here is too big to ignore. While I agree on the principle that the selectors should only be called when needed, I think the |
Looking into it some more, this isn't an issue with filters, but the Can we revert this? The regression is currently blocking a few PRs. |
This makes sense to me, it's a small PR that we can bring back if we figure out the issues. |
I contemplated a bit more about this proposal. If you look at it only from the performance perspective, it can’t be more performant than keeping |
Description
Ideally the only piece of context is the block client ID and everything else is derived from that. Unfortunately
useBlockEditContext
is exported at the package level (not sure why because it's only used within the package), but it can be rewritten withuseSelect
.After this we should create a new hook to only return the client ID, but I ran into some errors there which I'm trying to pinpoint. Doing this step by step instead.
How has this been tested?
Screenshots
Types of changes
Checklist: