What are safe practices when updating multiple interdependent states in react (and functional programming in general)?
I’ve asked a similar question recently, but the situation was rather esoteric, so I’m rephrasing with a simpler example that demonstrates the problem. The rules of the game are simple, when either red or blue scores a goal, the totalScore
is adjusted by the current pointsPerGoal
. Before the totalScore
is updated, however, the pointsPerGoal
is adjusted by plus or minus one points for blue and red respectivley: