Identifying Over-Hoisted State
What you'll learn: How to spot when state is placed too high in your component tree, causing unnecessary re-renders in unrelated components.
The Problem with State Living Too High
When state lives in a parent component but only affects one child, every sibling component re-renders whenever that state changes—even if they don't use it. This is "over-hoisted" or "lifted too high" state.
Think of it like a building's alarm system. If pulling the fire alarm in one apartment triggers every apartment's sprinkler system (even those without fire), you've got an over-hoisted alert mechanism. Ideally, only affected units should respond.
Common Symptoms
You'll recognize over-hoisted state when:
- A parent holds state that only one child cares about
- Sibling components re-render despite not using that state
- Props are passed down through components that don't read them (prop drilling to one branch)
- Profiler shows multiple components updating when only one needed to
The Pattern to Watch For
<Parent> ← State lives here
<SidebarA /> ← Doesn't use state, but re-renders
<SidebarB /> ← Doesn't use state, but re-renders
<MainContent /> ← Actually uses the state
</Parent>
Even with React.memo on the sidebars, if they receive any props that change due to referential instability from parent re-renders, the memoization fails. The root issue is state placement.
The Solution Direction
Moving state down into <MainContent> itself (or extracting it into a wrapper component) means Parent never re-renders for that state, so siblings never even get the bailout check.
Key Takeaway: State should live as close as possible to where it's actually used. When you see siblings re-rendering unnecessarily, check if their parent is holding state meant for just one child.