4 ms·
How do they even improve performance with Redux? If the whole state is one immutable tree, then the next state is a new tree and the whole app had to be render
by k__ 11y ago
How do they even improve performance with Redux?
If the whole state is one immutable tree, then the next state is a new tree and the whole app had to be rendered again.
I know it probably doesn't work like that, but this is what I think when I read about immutability.
- spion 11y agoI imagine it works somewhat like this example: If the toplevel object contains 3 items: { messages: list users: list me: object } and the toplevel component contains 3 components that correspond to these 3 sub-states: MessageList, UserList, MyInfo then updating the user list will only cause a re-render of the toplevel component and UserList, but not MessageList or MyInfo or their child components (the same VDOM will be reused and no diff / patching will be performed on that part of the VDOM / DOM, respectively) Something like if (this.shouldComponentUpdate(...)) { return this.render(...) } else { return this._oldVDOM; } then the diff algorithm can quickly compare by reference equality and only fall back to deeper object equality if the reference equality returns false.
- k__ 11y agoAh. I thought the diff would re-render all children, if their parent state changed.