I'm wondering about a fundamental working in REACT. It's relevant to understand whether my code contains racing conditions. I can't really think of an easy test to check how it works.
Assume the following situation.
We have a component X that is the parent of a child component Y.
this.state.x in the component X is given as a property to the component Y.
if we reset this.state.x the component Y will rerender.
Assume that we reset the state of X 3 times sequentially. Say first to 1 then to 2 and then to 3.
If we reset the x to 1 and then while Y is rerendering we set it very quickly to 2 and then 3.
My question is, if we set x to 2 and 3 while Y is still rerendering with x=1, does Y rerender one time with x=2 and one time with x=3 or only one time for x=3?
question from:
https://stackoverflow.com/questions/65947270/in-react-is-a-rerender-always-triggered-for-each-state-reset-individually 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…