Skip to content
tezvyn:

How does React's scheduler prioritize updates with Fiber?

Source: dev.toHardHow cards are made

How does React's scheduler prioritize updates with Fiber?

Tests cooperative scheduling. Cover Fiber's incremental units, the Scheduler's time-slicing loop, and Lanes where SyncLane and InputContinuousLane outrank DefaultLane. Red flag: claiming React uses a separate thread or that batching alone handles priority.

What's really being asked

Whether you understand React's concurrent rendering internals beyond the public API. Interviewers want to see that you know Fiber is not just a virtual DOM implementation but a re-architecture enabling interruptible rendering, and that you can explain how the Scheduler uses priority lanes to keep user interactions responsive under heavy load.

The full answer

First, the Fiber architecture breaks component rendering into small units of work linked in a tree where each node knows its parent, child, and sibling. This lets React pause and resume traversal. Second, the Scheduler sits above the reconciler and decides when to process work using a time-slicing loop that yields control back to the browser after roughly five milliseconds to avoid dropping frames. Third, updates are tagged with Lanes that act as priority highways. SyncLane handles immediate events like button clicks and form submissions. InputContinuousLane covers ongoing input like typing. DefaultLane is for standard updates such as data fetching. IdleLane runs background work only when the browser is free. Fourth, higher priority updates can interrupt lower priority work in progress. When interrupted, React throws away the partial work-in-progress tree and restarts from the root for the urgent update, then later resumes or restarts the background task.

The mistakes people make

Claiming React uses Web Workers or a separate thread for concurrent mode is a major red flag because all React work runs on the main thread and relies on cooperative yielding. Another mistake is saying that setState batching alone determines priority; batching groups updates but lanes determine which batch runs first. Some candidates also confuse the render phase with the commit phase, forgetting that render is pure and interruptible while commit is synchronous and must apply DOM changes and effects without stopping.

What usually comes next

How does useTransition leverage DefaultLane to mark updates as non-urgent? What happens when a high-priority update arrives while React is already committing? Can you explain starvation and how the Scheduler prevents low-priority lanes from waiting forever? How does time-slicing interact with the browser's event loop compared to requestIdleCallback?

A concrete example

Imagine a search input that filters a list of ten thousand items. When the user types, each keystroke triggers an InputContinuousLane update for the input value. The filtered list computation is wrapped in startTransition, which assigns it DefaultLane. If the user types quickly, the Scheduler interrupts the expensive list render after a few milliseconds, processes the next keystroke on InputContinuousLane, and only finishes the list update once typing pauses. Without lanes, every keystroke would block until all ten thousand items re-rendered, causing jank.

Interview question

What happens when a SyncLane update arrives while React is in the middle of a DefaultLane render?

  • a.React pauses the DefaultLane render and resumes it exactly where it left off after processing the SyncLane update, preserving the partial tree.
  • b.React completes the current DefaultLane render before handling the SyncLane update, since interrupting would corrupt the work-in-progress tree.
  • c.React interrupts the DefaultLane render, discards its partial work-in-progress tree, and restarts from the root to process the SyncLane update first.Correct
  • d.React processes the SyncLane update on a separate background thread while continuing the DefaultLane render on the main thread.
Why?

Higher-priority lanes can interrupt lower-priority renders, so React discards the partial work-in-progress tree and restarts from the root for the urgent update. Option A is tempting because Fiber enables pausing, but React does not preserve the partial tree for the interrupted task—it later restarts the background work rather than resuming exactly where it left off.

Just read this? Test yourself on what you have been reading.

Read the original → dev.to

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on react — each one lists the topics its interview covers.

See open roles