Menu

1 / 5

How React Works (Part 3)? How React Finds What Actually Changed

DEV Community·Sam Abaasi·6 months ago
#TKR8rQXY
Reading 0:00
15s threshold

How React Finds What Actually Changed

Series: How React Works Under the Hood

Part 1: Motivation Behind React Fiber: Time Slicing & Suspense

Part 2: Why React Had to Build Its Own Execution Engine

Prerequisites: Read Parts 1 and 2 first.

Where We Left Off

In Part 2 we understood the engine — Fiber gives React a custom call stack it controls, and the Scheduler decides what to run and when.

Now the question is: what does React actually do with that engine?

Every time state changes, React has a problem. It knows the old version of your UI and the new version. But it's working with a tree of potentially thousands of components. Re-creating or re-rendering all of them on every update would be catastrophically slow.

React needs to answer one question as efficiently as possible:

"Of everything that could have changed, what actually did?"

The algorithm that answers that question is called the Reconciler .

The Problem: Re-rendering Everything Is Too Slow

Let's make the problem concrete.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.