You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An existing context API will be phased out in v17, thus an approach to the stores need to be revised.
First, we will need to define the global Provider/Consumer pair for the store. Then, the component exposing the store need to inject render() method wrapper thus the store will be exposed. That's an easy part.
The store must be properly resolved in render() methods across the tree. There are two possible ways of achieving that.
Wrap the consumer's render method.
Create the wrapper component which will inject the store as prop. Like useStore( MyComponent ).
The second method is less magical and guarantees that the store lookup chain will be initialized properly.
The way how the store is defined might be changed as well. It can be:
The dedicated base class StoreComponent which uses the Store class as a base class for its state, and automatically exposes the state using the render() wrapping technique. We need to make sure that attributesIO endpoint skips members with empty endpoints.
The dedicated base class which uses separate members for the store and state as it is now.
The dedicated wrapper function exposing the store and injecting it into the component's prop. Like that: exposeStore( MyComponentStore, MyComponent ).
The last option will unify the usage of stores in parent and children components, and allow for integration of the store prefetch logic.
In general, HOF approach creating the wrapper components seems to be favorable.
The text was updated successfully, but these errors were encountered:
An existing context API will be phased out in v17, thus an approach to the stores need to be revised.
First, we will need to define the global Provider/Consumer pair for the store. Then, the component exposing the store need to inject
render()
method wrapper thus the store will be exposed. That's an easy part.The store must be properly resolved in render() methods across the tree. There are two possible ways of achieving that.
render
method.useStore( MyComponent )
.The second method is less magical and guarantees that the store lookup chain will be initialized properly.
The way how the store is defined might be changed as well. It can be:
render()
wrapping technique. We need to make sure thatattributesIO
endpoint skips members with empty endpoints.store
andstate
as it is now.exposeStore( MyComponentStore, MyComponent )
.The last option will unify the usage of stores in parent and children components, and allow for integration of the store prefetch logic.
In general, HOF approach creating the wrapper components seems to be favorable.
The text was updated successfully, but these errors were encountered: