Two kinds of components
As your app grows, you’ll naturally split components into two roles:UserDashboard knows about APIs and state. UserList and UserCard know nothing about where data comes from — they just display what they receive. This separation makes presentational components reusable across your app.
Lifting state up
When two sibling components need the same data, move the state to their shared parent:UserPage owns the state. SearchBar updates it via a callback. UserList reads the filtered result. Neither child knows about the other — the parent coordinates everything.
“Lifting state up” is the answer to “how do sibling components share data?” Move the state to the nearest common parent. The parent passes data down via props and receives updates via callback props.
Callback props — child-to-parent communication
Props flow down (parent → child). For the reverse direction, pass a function as a prop:TodoApp owns all the state and logic. Children communicate back by calling the callback props (onAdd, onToggle, onDelete). No child modifies state directly.
A full composition example
Here’s a realistic page that combines everything — fetch, state, forms, lists, and composition:DashboardPage handles all API calls and state. CreateUserForm has local state for the input fields, but the actual “create” logic lives in the parent. UserTable is pure display.
Rules of thumb
- State goes in the highest component that needs it — not higher, not lower
- If two components need the same data — lift the state to their parent
- Smart components fetch and manage — presentational components display
- Callback props for child → parent — never modify parent state directly from a child
- Local state is fine for UI-only state — form inputs, open/closed toggles, hover states
What’s next?
You’ve learned the React essentials — components, props, state, effects, conditional rendering, lists, forms, and composition. These 8 concepts cover 90% of what you’ll do in React. Now let’s put it all together. In the next section, you’ll connect your React frontend to a FastAPI backend and build a complete full-stack application.Full-stack project structure
Organize a project with a React frontend and FastAPI backend