when you setLocalState, you update your state to 0 and pass it to the hook, that is one render
useEffect only run at the next render and if there is a change in dependencies, so the first render has to run first (with old value), then it trigger useEffect that set another state and trigger another render, only by that you have the correct value
but i have to say this is a very odd way to update the state, there is pattern that is much better
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
because it happens in different render
when you setLocalState, you update your state to 0 and pass it to the hook, that is one render
useEffect only run at the next render and if there is a change in dependencies, so the first render has to run first (with old value), then it trigger useEffect that set another state and trigger another render, only by that you have the correct value
but i have to say this is a very odd way to update the state, there is pattern that is much better