Using a function in `setState` instead of an object
Sophia Shoemaker
2.2K27

Sophia, in your codepen below you have two set state calls and I understand that the instruction to increment the counter is only getting called the in the BadCounter class because of Reacts update batching. However, the example seems contrived and I can’t think of a situation where I would need to call setState() twice in one handler function. Can the problem also surface if one is only calling setState() once?

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.