-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dumb/smart component pattern and repaints #75
Comments
React-Redux implements a pretty aggressive That said. If the smart component does trigger a re-render and you are concerned about performance then you should implement |
I am not so much concerned about performance yet but I think many people are and that should be addressed in the docs. As you said:
In that case in the simple todo example form the doc, why would the footer component re-render when a todo is added? It doesn't share any state with the todo list. |
This is a consequence of how React works, and react-redux actually improves the situation. In no way does That said, the footer in this example shows the todo count so it rightly does need to be re-rendered. but I believe that is beside your point. bottom line is store subscriptions do not produce additional render noise as long as you are only subscribing to the slice of state the given component tree has an interest in reacting to. |
not sure, i'm talking about this here: https://github.com/rackt/redux/blob/master/examples/todomvc/components/Footer.js#L51
yes that's fair to say but I don't think it has a particularly deep implication for how one should structure their app. |
Put |
Thanks, so one connect() at the top most level is the approach you'd recommend? It'd nice to have this statement in the docs somewhere, it'd help understanding the whole redux flow. Maybe a "flux like" diagram would help there as well.
Then we would have multiple connect() for all main "containers" connecting to the main store ? |
There is no official recommendation on this, it really depends on the app. Usually I'd go for “one
Yes. |
Sorry to drag this up but i had a similar question. Because the props are passed from the top level root component, i.e the APP itself, it seems that every inherit component will render. This seems to be conflicting with React fundamentals where a full app render is taking place all the time? |
Actually you probably dont want to have your root component react to every changes in your store. It should only propagate the "global" state changes like maybe a session change or a language switch. |
I said in the above comment that nobody forces you to connect just once. You can have as many connected components as you like. This addresses any potential performance bottlenecks. |
Using the dumb/smart components pattern, does it mean that all dumb components will be re-rendered when the "containers" receive a new state notification ? For example in the the todo example adding a todo to the list will re-render the whole app.
Are there any pattern to optimise repaints in a larger app ?
The text was updated successfully, but these errors were encountered: