In React version < 17, it understands the execution context (important to note) and batches the setState calls as per that. No matter how many successive setState calls we make in a React event handler, it will only produce a single re-render at the end of the event and reflects the state accordingly.

To know more, checkout --

For useful and amazing frontend and programming tutorials: