Closed tadjik1 closed 9 years ago
Please see https://github.com/rackt/redux/issues/419.
Both approaches are fine, and having nested connect()
components is actually going to give you more performance. The downside is they're slightly more coupled to the application and slightly harder to test, but that may not be a big issue.
thanks!
I recommend usage of redux-batched-updates as it can avoid some serious headaches. See 3.0.0 release notes. It will also improve performance in some cases.
I started wondering the same thing, whether connect
was intended to be used on ± every component individually, or only on the top level component. The link @gaearon gives is broken, I think https://github.com/reactjs/redux/issues/419 is the correct thread to refer to for more discussion.
The current answer to this question is in the Redux FAQ. See http://redux.js.org/docs/faq/ReactRedux.html#react-multiple-components . My recent blog post at http://blog.isquaredsoftware.com/2017/01/practical-redux-part-6-connected-lists-forms-and-performance/ also discusses the idea of multiple connected components and performance.
@gaearon update for rotten link: https://github.com/reactjs/redux/issues/419
The current answer to this question is in the Redux FAQ. See http://redux.js.org/docs/faq/ReactRedux.html#react-multiple-components . My recent blog post at http://blog.isquaredsoftware.com/2017/01/practical-redux-part-6-connected-lists-forms-and-performance/ also discusses the idea of multiple connected components and performance.
Updated link: https://redux.js.org/faq/react-redux#should-i-only-connect-my-top-component-or-can-i-connect-multiple-components-in-my-tree
On each page on my website I have many components and I don't want to control fetching and grabing data from store for every component just in one "smart" top-level component. So I want to connect nested components too. Is this a good pattern? Will I meet a perfomance troubles with this way of connect? What I need to know about connected components behavior for avoiding troubles?