Hi i'm an avid web and app developer in search for creativity and always going after new ideas.
Developer of Atomics Digital, Invoice Me and Reactor JS
I've used the way i showed you in many apps and it always works, never had it bug once. I'm not sure what you are doing in your example but this does not happen.
Not quite, again. The examples are the code snippets provided in this article, and the demo is found on the site I posted. So you can easily verify this.
The thing to note is that you will only run into trouble if the state updates are batched. So most of the time, you'll be fine writing the code without using a function, like you said. But, you will always be safe if you choose to write the code the correct way if it relies on the previous state, even if the state updates are batched. So it's safer to write it this way.
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.
I've used the way i showed you in many apps and it always works, never had it bug once. I'm not sure what you are doing in your example but this does not happen.
Not quite, again. The examples are the code snippets provided in this article, and the demo is found on the site I posted. So you can easily verify this.
The thing to note is that you will only run into trouble if the state updates are batched. So most of the time, you'll be fine writing the code without using a function, like you said. But, you will always be safe if you choose to write the code the correct way if it relies on the previous state, even if the state updates are batched. So it's safer to write it this way.