← BYTES
React.js·Intermediate·Ref: 4.2.7
In legacy (pre-React-18) behavior, if you call two separate `setState`/state-setter updates inside a single React event handler (like an onClick), what typically happens?
Have a question about this video? Mention reference 4.2.7 when you contact us.
a.React applies each one immediately and separately, causing two distinct re-renders
b.React throws a runtime error for calling setState twice in one handler
c.The second setState call is silently ignored
d.React batches them together and performs a single re-render reflecting both updates
Inside React's own event handlers, pre-18 React already batched multiple state updates into a single re-render for efficiency -- this is different from calls made outside React's control flow (like inside a raw `setTimeout` or a promise callback), which weren't batched before React 18's automatic batching.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES427#Reactjs