Open niamleeson opened 4 years ago
Here's a use case. I think the API would be really nice.
import { State } from './state.provider'; const Parent = () => { const { handleAction, currState, component: Component } = State.useContainer(); return ( <Component sendAction={handleAction} pollData={pollData} /> ); }; export default State.withContainer(Parent);
Without the above, you need to do this everytime you create a new state:
import { State } from './state.provider'; const withContainer = (Component) => (props) => ( <State.Provider> <Component {...props} /> </State.Provider> ); const Parent = () => { const { handleAction, currState, component: Component } = State.useContainer(); return ( <Component sendAction={handleAction} pollData={pollData} /> ); }; export default withContainer(Parent);
Here's a use case. I think the API would be really nice.
Without the above, you need to do this everytime you create a new state: