The current documentation for setting state hooks is shown as:
<button onClick={() => setCount(count + 1)}>
However wouldn't it be much better to use the previous state?
<button onClick={() => setCount(prevCount => prevCount + 1)}>
This would be more consistent with the original setState documentation.
I have also personally had issues with states being handled incorrectly due to using the documented method of setting state with the rendered state.
Wouldn't this prevent a lot of logical errors people may face due to the documentation?
The current documentation for setting state hooks is shown as:
However wouldn't it be much better to use the previous state?
This would be more consistent with the original setState documentation.
I have also personally had issues with states being handled incorrectly due to using the documented method of setting state with the rendered state.
Wouldn't this prevent a lot of logical errors people may face due to the documentation?