For example, a component has the initial state of {loading: true, setup: true}
and when changing states like this:
this.setState({
loading: false,
setup: false
})
Are there any chances at one point that loading
is false
and setup
is still true
on the real DOM? Because as far as I know (correct me if I'm wrong), the process of updating through VDOM is the following:
diff queue
requestAnimationFrame
), batch all the changes that are in diff queue
. Then apply all the mutations to the DOM in order.Since we apply all the patches to the DOM in order, so I assume there will be a time where loading: false
and setup: true
?
is there a time where
loading
isfalse
andsetup
istrue
?
No, I'm pretty sure there is no chance to setState
could be split into separate updates that could be passed separately to DOM.
It's not working that way.
First: VDOM will be updated with both changes at once, in one fn call.
Second: DOM won't be updated with "partially ready" updates. When some (parallel) processes are not ready diffing (since Fiber) can delay fragments of DOM updates.