Merged
Conversation
ellatrix
commented
Feb 10, 2021
|
Size Change: +82 B (0%) Total Size: 1.38 MB
ℹ️ View Unchanged
|
ntsekouras
reviewed
Feb 10, 2021
Contributor
ntsekouras
left a comment
There was a problem hiding this comment.
Thanks for looking at this so fast Ella! 🚀
packages/block-editor/src/components/block-list/use-block-props/use-event-handlers.js
Show resolved
Hide resolved
youknowriad
reviewed
Feb 10, 2021
packages/block-editor/src/components/block-list/use-block-props/index.js
Outdated
Show resolved
Hide resolved
ntsekouras
approved these changes
Feb 11, 2021
Contributor
ntsekouras
left a comment
There was a problem hiding this comment.
I have tested and it works as expected - thanks Ella! 💯
4174544 to
fe83590
Compare
Contributor
Contributor
I'd wager that it worked properly. I didn't verify with bisect but I came to suspect this PR after I noticed in the Button block that |
7 tasks
stokesman
reviewed
Feb 21, 2021
packages/block-editor/src/components/block-list/use-block-props/index.js
Show resolved
Hide resolved
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Description
Fixes: #28880
Alternative to #28658.
I added a
useEffect-like cleanup pattern touseMergeRefs, which allows something to be cleaned up more easily than with the current way ref callbacks work. Ref callbacks are normally called withnullwhen a new one is called, but unless you set the node as a property of the ref callback, you don't have access to it. It's probably possible to do, but it makes the code much harder to understand than theuseEffectpattern that everyone already knows. So if a ref callback returns a cleanup function, we'll call the cleanup function instead of calling the callback a second time with null. It's still possible to have the old behaviour by simply not returning a cleanup function. I think this pattern will be very useful for many components switching from an effect hook to a ref callback.How has this been tested?
Screenshots
Types of changes
Checklist: