It's because it comes from an event, like a click on a button.
React currently will batch state updates if they're triggered from within a React-based event, like a button click or input change. It will not batch updates if they're triggered outside of a React event handler, like an async call.
I checked useState behavoiur and I have 1 render. See example codesandbox.io/s/sweet-star-er91q?...
It's because it comes from an event, like a click on a button.
React currently will batch state updates if they're triggered from within a React-based event, like a button click or input change. It will not batch updates if they're triggered outside of a React event handler, like an async call.
Yea, you're right. I didn't know it. Thanks. But what's reason for work batching only in event handlers?