Composite: use internal context to consume composite store#64493
Composite: use internal context to consume composite store#64493
Composite: use internal context to consume composite store#64493Conversation
|
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
tyxla
left a comment
There was a problem hiding this comment.
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:
and
| ) { | ||
| const contextValue = useMemo( | ||
| () => ( { | ||
| store, |
There was a problem hiding this comment.
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.
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
Compositesub-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 thestorefrom context instead of relying on Ariakit internalsTesting Instructions