Open utterances-bot opened 1 year ago
The preferred solution here would be simply to store the next state in a local variable and pass that into both the setter function and the moveNext function.
You can read the new react docs on getting rid of useless effects like this to better understand what I mean
Loving the site design btw👌
Using value of state variables right after updating in React.js — Amit Merchant — A blog on PHP, JavaScript, and more
Working on one of the apps which built on top of React.js, I stumbled upon a scenario where I needed to use the value of a state variable immediately after it’s updated.
https://www.amitmerchant.com/using-value-of-state-variables-after-updating-in-react/