Why redux suggests to only connect to top level components?

后端 未结 5 443
悲哀的现实
悲哀的现实 2020-12-25 12:53

I\'m new to redux and react-redux, in the mean time I am trying to make a redux app.

I don\'t understand the statement on redux document:

Then

5条回答
  •  青春惊慌失措
    2020-12-25 13:23

    When I had one container at the top, I had efficiency problems because React rerendered all my components during slightest update somewhere in the tree. So I abandoned that approach and made my app against docs, which turned out to be faster.

    But later I've seen that even Redux author wrote on his Twitter:

    Emphasizing “one container component at the top” in Redux examples was a mistake. Don’t take this as a maxim.

    https://twitter.com/dan_abramov/status/668585589609005056

    and

    Try to keep your presentation components separate. Create container components by connecting them when it’s convenient. https://twitter.com/dan_abramov/status/668586001175048192

提交回复
热议问题