Skip to content

FlashcardNot attempted

The two trees

Recall it before you reveal

What are the "current" and "work-in-progress" trees, and what does the alternate pointer do?

Space to reveal
Show answer & explanation

React keeps two fiber trees: current (what's on screen) and work-in-progress (being built for the next update). Each fiber's alternate points to its counterpart in the other tree.

After commit, React swaps them: WIP becomes current, and the old current is recycled as the next WIP instead of being thrown away (double buffering, like in graphics).