This question is about internals for partial re-renderings with React-Redux.
To explain what I mean, I will first introduce a very crude technique for managing state without any state management libary. The technique uses a a huge "AppState"-object that is owned by the top-level App-component. Suppose that this AppState holds not only state-properties, but also several callbacks that mutate those state-properties. Furthermore, suppose that we use props to pass down this AppState throughout the entire component hierarchy. Thanks to the ES6-spread syntax, passing a huge number of props can be done without a lot of boilerplate code. In the top-level App-component, it will look like this:
<ChildComponent {...this.state} />
In all other components, it will look like this:
<GrandChildComponent {...this.props} />
It is important to note that the ES6-spread syntax does not actually pass the AppState-object. Instead, it extracts all the AppState-properties and passes them as separate props.
Now we should distinguish between top-level properties and nested child-properties of the AppState:
- If I mutate a top-level property of this AppState by calling setState, then the entire app will re-render (unless I use things like pure components).
- However, if I change a nested child-property of this AppState, then nothing will happen because React does not notice the property change.
This leads to my final questions:
- What is the render-performance of this crude approach in comparison to Redux?
- How exactly does Redux handle "partial renderings", such that only some of the Components re-render after a state mutation?