DEV Community

Discussion on: React with Typescript

Collapse
lukeshiru profile image
LUKESHIRU • Edited on

You're wrong, if you set all fields at once, that re-renders once, the state changes don't run in place, but actually are scheduled. I explained the reasoning for the types in other comment, but is because is the actual type used by event handlers in React. If that changes, you'll get type errors that you can actually resolve :D

Thread Thread
theluk profile image
Lukas Klinzing

You are right, but as I said, partly.

"Currently (React 16 and earlier), only updates inside React event handlers are batched by default” , according to Dan Abramov.

And

"React may batch multiple setState() calls into a single update for performance”, according to React’s documentation

So it is possible, that it is not batched.