Lanes and the Scheduler
A lane is one bit in a 31-bit integer. Every update gets one lane, and a render processes a set of lanes (a bitmask), so batching, priority, entanglement and "which updates did…
Archive
30 notes match these filters
A lane is one bit in a 31-bit integer. Every update gets one lane, and a render processes a set of lanes (a bitmask), so batching, priority, entanglement and "which updates did…
root.render(<App />) does not render. It picks a lane (normally DefaultLane), wraps the element in an Update {payload: {element}}, stashes the update in a global concurrent queue…
createRoot(container) renders nothing. It checks the container, builds two linked objects, and attaches every event listener React will ever need to the container. The two objects…
react is a small package. It builds plain element objects (jsx()) and holds one shared mutable object, ReactSharedInternals, with slots like H (the hooks dispatcher) and T (the…
React does its work in two phases. The render phase is pure and can be interrupted (in practice only for transition, retry and idle work, because the first mount and clicks render…
beginWork(current, wip, renderLanes) does one of two things for each fiber. Either it bails out (props object identical, no scheduled update or context change, so it reuses…
completeRoot → commitRoot applies a finished work-in-progress tree to the DOM synchronously and without yielding, in fixed sub-phases. Before mutation reads DOM state…
completeWork runs on the way up the tree, once all of a fiber's children are done. For a newly mounted host fiber it creates the real DOM node (createInstance →…
setCount(x) is dispatchSetState(fiber, queue, x). It picks a lane from the current event priority or transition, and may compute the new state eagerly and drop the update when…
On a re-render, renderWithHooks installs HooksDispatcherOnUpdate. Each hook call then clones the matching node from the committed (current) fiber's hook list onto the…