1 min readAug 23, 2020
When using previous state to update current state, the preferred approach is to pass a function to the state setter, such as `setVarA(a => a + 1)`.
Not only does this make sure `varA` is updated to the latest value in case something changed asynchronously, but it also gives you the option of removing `varA` from the dependencies if your effect is actually dependent on a different trigger, such as a true/false flag.