A
A
Anton Perevoshchikov2017-11-03 16:30:15
JavaScript
Anton Perevoshchikov, 2017-11-03 16:30:15

How to correctly pass dispatch to a child component?

Now I'm dealing with one project, before that I didn't work with React and Redux.
There is the following structure:

<App>
  <Child>
    <SubChild></SubChild>
  </Child>
</App>

Appwrapped in connect and forwarded SubChildthrough Childdispatch. At the same time, Child'уhe himself is not needed. And so everywhere.
Is this approach considered normal?
Or is it possible to SubChildwrap it in connect and not deal with dispatch forwarding?
I read that the component should not know about any disaptch and actions, it's better to use mapDispatchToProps.
Is it correct to use connect for nested components?
What is considered best practices?
UPD: marked the correct solution. In short: use connect for containers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2017-11-03
@Fett

https://medium.com/@dan_abramov/smart-and-dumb-com...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question