React 18 introduces Automatic Batching. Automatic Batching is the process by which React batches state updates that happen in a "micro-task" in a single state cycle. Previously, React batched state updates that happened in a single event callback managed by React system, however state updates that happened within timeouts, promises, or native event handlers were not batched. Here is an example that explains it -
[JSByte by Shruti Kapoor] What is Automatic Batching in React 18?
[JSByte by Shruti Kapoor] What is Automatic…
React 18 introduces Automatic Batching. Automatic Batching is the process by which React batches state updates that happen in a "micro-task" in a single state cycle. Previously, React batched state updates that happened in a single event callback managed by React system, however state updates that happened within timeouts, promises, or native event handlers were not batched. Here is an example that explains it -