正在加载视频...

视频加载失败

⚛️ 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 次观看 • 2 年前 •via X (Twitter)

10 条评论

George Moller 的头像
George Moller2 年前

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 ↓

George Moller 的头像
George Moller2 年前

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 ↓

Shivam Jha 的头像
Shivam Jha2 年前

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

George Moller 的头像
George Moller2 年前

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

Pavel Romanov 的头像
Pavel Romanov2 年前

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

George Moller 的头像
George Moller2 年前

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

Jamal Ahmad 的头像
Jamal Ahmad2 年前

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

George Moller 的头像
George Moller2 年前

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.

Osama 的头像
Osama2 年前

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

George Moller 的头像
George Moller2 年前

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.

相关视频