Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

⚛️ Do you know what Automatic Batching means in React (v18)? It means that React groups multiple state updates into a single re-render for better performance. ↓

61,817 Aufrufe • vor 2 Jahren •via X (Twitter)

10 Kommentare

Profilbild von George Moller
George Mollervor 2 Jahren

I've been working professionally with React for more than 8 years and I compiled all my knowledge into 100+ infographics and 50+ video animations just like this one. Check them out ↓

Profilbild von George Moller
George Mollervor 2 Jahren

I've been working professionally with React for more than 8 years and I compiled all my knowledge into 100+ infographics and 50+ video animations just like this one. Check them out ↓

Profilbild von Shivam Jha
Shivam Jhavor 2 Jahren

Here’s a post explaining this in detail (shameless plug)

Profilbild von George Moller
George Mollervor 2 Jahren

Minor correction: it should read we have 3 todos at the end of the last render.

Profilbild von Pavel Romanov
Pavel Romanovvor 2 Jahren

Didn't know about this feature. Would love to see more content on rendering like React Fiber and others

Profilbild von George Moller
George Mollervor 2 Jahren

It was super fun to make this so I might just make more about react rendering process Pavel :)

Profilbild von Jamal Ahmad
Jamal Ahmadvor 2 Jahren

I didn't not understand because the code looks the same at the end

Profilbild von George Moller
George Mollervor 2 Jahren

The code is the same. What changes is how react batches updates. Before each setState triggered a new re-render. After React 18, react batches setStates and only does one render at the end.

Profilbild von Osama
Osamavor 2 Jahren

Count is derived state anyway, needless to use state for it but I understand the topic is something else

Profilbild von George Moller
George Mollervor 2 Jahren

You are right, that and the fetch inside useEffect were just added for context. Would derive cont from state and also wouldn't fetch in useEffect.

Ähnliche Videos