mantra-sample-blog-app icon indicating copy to clipboard operation
mantra-sample-blog-app copied to clipboard

how to bind some arg to all actions ?

Open lyquocnam opened this issue 8 years ago • 1 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 !

lyquocnam avatar Apr 06 '16 16:04 lyquocnam

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? 😬

markshust avatar Jul 13 '16 02:07 markshust