Do you still need help with this? If so, would you mind creating a minimal reproducible example on something like CodeSandbox? That would make it easier for us to see what's going on :)
What I can say is that whenever you need to set state based on a previous value, like when you're flipping shouldStop, instead of doing setShouldStop(!shouldStop), try setShouldStop(prevShouldStop => !prevShouldStop). This ensures that you're always using the latest shouldStop to update it instead of accidentally using a previous value: reactjs.org/docs/hooks-reference.h...
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.
Hi @ptifur ,
Do you still need help with this? If so, would you mind creating a minimal reproducible example on something like CodeSandbox? That would make it easier for us to see what's going on :)
What I can say is that whenever you need to set state based on a previous value, like when you're flipping
shouldStop
, instead of doingsetShouldStop(!shouldStop)
, trysetShouldStop(prevShouldStop => !prevShouldStop)
. This ensures that you're always using the latestshouldStop
to update it instead of accidentally using a previous value: reactjs.org/docs/hooks-reference.h...