What Happens on First Render
What you'll learn: How React builds its internal hook list the very first time your component renders.
The First Execution is Special
When a React component mounts for the first time, React doesn't yet know anything about what hooks you'll use. It has to discover them by literally running your component function and watching what hooks get called.
As your component executes top-to-bottom, each hook call registers itself in React's internal storage. React creates an entry in its hook registry and links them together in a sequential list. The first useState becomes slot 0, the second useState becomes slot 1, the first useEffect becomes slot 2, and so on.
The Sequential Recording Process
Think of it like taking attendance on the first day of class. React has an empty roster and a pen. As each hook "shows up" by being called, React writes it down in order:
- Component function starts executing
- First hook call → React creates entry #0
- Second hook call → React creates entry #1
- Third hook call → React creates entry #2
- Component function completes
- React now has a complete hook list for this component instance
This list becomes the permanent structure React expects on every future render. That's why changing the order or number of hooks later breaks everything—React would be reading from the wrong slots.
Why This Matters
Understanding first render helps you see why conditional hooks are forbidden. React has no way to "skip a slot" or "insert a new slot later"—the initial order is set in stone.
Key Takeaway: On first render, React builds a sequential hook list by recording each hook call in order as your component executes—this list structure must remain identical on all future renders.