DEV Community

Discussion on: What a React developer needs to know in 2021

Collapse
 
pcockerell profile image
Peter Cockerell

How so?

Thread Thread
 
vberen profile image
Nicklas Wessel

Because of the async nature.
If you spam the button it might only increment it by one, since the state at that point at the second click isn't updated yet.

Thread Thread
 
pcockerell profile image
Peter Cockerell

Ah, got it, thanks!