Add RegistryProvider to all React apps
See original GitHub issueFeature Description
In order for all components to have access all datastores, we should wrap all of our React apps with a RegistryProvider to avoid the need to add this provider to each individual component.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- All React apps (e.g.
GoogleSitekitDashboard) should wrap their children in a<Root>component. - The
<Root>component should wrap any app in all of the required components (ErrorHandler,Data.RegistryProvider, etc.) - Wrapping should be consistent across all apps
Implementation Brief
- Create a new component (“
Root”) inassets/js/components/root/index.js - Wrap
childrenpassed to<Root>in<Data.RegistryProvider value={ Data }>and<ErrorHandler>, to begin 😄 - It likely makes sense to allow a custom registry to be passed to
<Root>for testing, so it should accept aregistryprop whose default value isData. - Add
googlesitekit-datato the common$dependenciesarray shared by all main entrypoints inAssets::get_assets()
QA Brief
Changelog entry
- Wrap all JavaScript apps into
Rootcomponent with essential providers, error handlers etc.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Building a Component Registry in React - Medium
What if you have a list of hundred of components but your project just uses a few and you don't need to import...
Read more >Create a New React App
Create React App is a comfortable environment for learning React, and is the best way to start building a new single-page application in...
Read more >Context - React
Context provides a way to pass data through the component tree without having to pass props down manually at every level. In a...
Read more >Components and Props - React
The simplest way to define a component is to write a JavaScript function: ... A button, a form, a dialog, a screen: in...
Read more >@wordpress/data - npm
WordPress' data module serves as a hub to manage application state for ... Use the register function to add your own store to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks for the additional context @aaemnnosttv and @tofumatt! That all sounds good to me, IB ✅
Let’s stick with consistently using lowercase file/directory names for components for now, this is not the right point to change it. I’m in favor of making the change overall (as I think it’s a great way to easily differentiate components), but it should happen with a separate issue at some point.
Yeah. The registry is just provided via Context to all child components. We only need it once so it makes component refactoring simpler as well. I’ve added this issue as a dependency of #1531 for this reason.
There should be no downside to adding this. I would imagine that if there was @tofumatt would have flagged that but a quick POC shows that everything seems to work fine 😄
One thing I did notice though is that we need to also enqueue
googlesitekit-dataeverywhere as well. I’ll add this to the IB.