2 ms·
I imagine it works somewhat like this example: If the toplevel object contains 3 items: { messages: list users: list me: object } and the toplevel
by spion 11y ago
I 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.