-
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
Composite
: use internal context to consume composite store
#64493
Composite
: use internal context to consume composite store
#64493
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Composite
: add internal context to make sure that sub-components consume the correct storeComposite
: use internal context to consume composite store
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.
LGTM 👍 🚀
I'd only add some documentation that includes that the store is passed down through context and should be consumed through useCompositeContext()
.
Also, let's make sure to update the instances that still provide store explicitly to Composite
subcomponents, for example:
gutenberg/packages/block-directory/src/components/downloadable-block-list-item/index.js
Line 117 in 2c62c6a
store={ composite } |
and
store={ store } |
) { | ||
const contextValue = useMemo( | ||
() => ( { | ||
store, |
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.
Let's document this so folks know that if they want to access the store inside a Composite
, they can do it with the 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.
Added JSDocs and README section
I've added
Passing |
Flaky tests detected in b30b0c4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10387982068
|
What?
Use React context to make sure that
Composite
sub-components use the correct composite contextWhy?
Since multiple ariakit components use composite stores in their internal implementation, sometimes sub-components can consume the wrong composite store (see #63569 (comment))
How?
Add a new context that holds a reference to the correct composite
store
. Subcomponents get thestore
from context instead of relying on Ariakit internalsTesting Instructions