React ships its own cooperative scheduler, the scheduler npm package: internal to React, with no finalized public API, and unrelated to the browser's scheduler.postTask().
Queueing. When a root has work that isn't flushed synchronously, React schedules a callback with a priority: user-blocking for input lanes, normal for default updates, Transitions and retries, idle for the idle lane. Each priority sets a timeout (250 ms, 5 s, never), and tasks wait in a min-heap ordered by expiration time.
Running. The scheduler doesn't run tasks directly. It asks the browser for a task by posting a message on a MessageChannel, and in that message handler runs queued callbacks in order. Not setTimeout(fn, 0): the source comment cites the 4 ms clamp on nested timers. Not requestAnimationFrame either: the work doesn't need to line up with frames.
Yielding. React's concurrent work loop calls shouldYield() before every fiber. It returns true once 5 ms (frameYieldMs) have passed since the browser task started, or straight after a commit so the browser can paint it. React then stops, keeping its place in workInProgress, and returns a continuation. The scheduler keeps it as the same task, posts another message and returns, ending the browser task. Input and rendering run, then the message arrives and work resumes. A click that arrives meanwhile may schedule an urgent update, and React restarts with it.
What doesn't go through this path:
- Sync-lane updates (click, keydown, input) render in the event's own task, with no messages and no yielding.
- Blocking lanes that do become scheduler tasks, like a
setTimeoutupdate, still render without callingshouldYield(). Only Transitions, deferred values, retries and hidden work are sliced. - Expired work. A task past its timeout runs without yielding, so starved updates finish.
It's cooperative: it stops only between components, never inside one.