- All Courses
- React Performance Engineering
- Taming Re-renders
- State colocation and lifting
Lesson 2.4
State colocation and lifting
Advice to lift state up is about correctness, not performance.
10mAdvanced6.7k students
Overview
Where state lives decides what re-renders
Advice to lift state up is about correctness, not performance. Lifted state re-renders everything below its new owner, so a value used by one input at the bottom of the tree should not live at the top of it.
Colocation is the counter-move: push each piece of state down until it sits at the closest common ancestor of the components that read it, and no higher.
When state genuinely must live high up, passing an expensive subtree through the children prop keeps it out of the re-render — it was created by the parent above and its element identity does not change.
In this lesson you will:
- Own state at the lowest node that needs it
- Recognise when lifting state is costing you renders
- Use children to keep a subtree out of a render
Resources
Notes are not saved yet — they clear when you leave this page.
Previous Lesson
Context without the re-render tax
6m
List virtualization
13m