-
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
@wordpress/data: Export entire registry context #15445
Conversation
This is needed for any consuming code that wants to implement the `useContext` hook for the registry.
- also fixes some wrapping in earlier changelog entry
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.
I think based on the availability of useContext
and its usage pattern, we should want to expose this object anywhere we also expose the provider and consumer subcomponents. If agreeable, we should consider auditing and creating a tracking issue.
For confirmation, this capitalization (UpperCamelCase) does seem to be what is promoted by React in their documentation:
@@ -381,6 +381,10 @@ _Returns_ | |||
|
|||
Undocumented declaration. | |||
|
|||
<a name="RegistryContext" href="#RegistryContext">#</a> **RegistryContext** |
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.
Can we make sure this is documented? See also #15176, which proposes documentation for RegistryConsumer
and RegistryProvider
.
I forgot about this pull! I think we should actually either close this or rework it so that it instead just exposes the |
@nerrad But |
In the case of for the registry, I think any implementation would just use We'd still need to export |
Okay, this seems like a good conservative default for now. My thinking was less about registry context specifically, but context consumers generally. I think we tend to not expose the consumers anyways (intentionally?), so no need to be premature with exposing the context object I suppose. The only potential downside is that if we do choose to have a generic pattern, we'd need to decide how to reconcile this with |
Good points there, but I think context (a a general term, not an intentional pun!) matters here. I think we should generally avoid exposing low level things from |
Fwiw, we probably could avoid exposing |
This pull is now invalid. There is a |
Description
As a part of the work being done on #15444, the
useContext
hook is being used to obtain theregistry
value from the context. However in order to do this the entire registry context object must be exposed from@wordpress/data
. This pull does so.This has utility for anywhere else where
useContext
might be implemented with the registry context.How has this been tested?
Types of changes
This is a non-breaking change and is an enhancement exposing the entire RegistryContext object. Existing Consumer and Provider values are left alone so there's no impact to existing code.
Checklist: