Yogesh Chavan
1 min readFeb 6, 2020

--

Jordan Corbman If we are having multiple setState calls one after the another or changing the state by calling another function after first setState call, then just passing object to setState has undesired result as can be seen here: https://codesandbox.io/s/hidden-rain-u6pib
counter should be 2 but it’s coming as 1 at the end because setState is asynchronous But if you use function syntax then it will work correctly as can be seen here: https://codesandbox.io/s/friendly-wildflower-14gm4

--

--

Yogesh Chavan
Yogesh Chavan

No responses yet