how to bind some arg to all actions ?
lyquocnam opened this issue · comments
hi everyone, i have a problem.
i want to send some objects to actions before component render. how can i do that ?
my currently solution:
<Button onClick={actions.bind(null, data)} label="OK"/>
but this i have to bind each action on my component, that's too bad.
how can i bind data object to all actions in once?
thanks so much !
I believe you need a container component to link actions down to presentational components. I've found it pretty consistent to have a related container component for practically every single presentation component that needs to manage a state or link up an action. Then, you pass the actions as props using useDeps
. It seems like overkill in theory, but in practice just about all of the container components are needed to properly manage the data aspect of the components.
Hope this helps? 😬