Recall & Review
beginner
What does it mean to share state between components in React?
It means making some data available to more than one component so they can all use or update it together, like sharing a common notebook between friends.
Click to reveal answer
beginner
How can you share state between a parent and its child component?
The parent holds the state and passes it down to the child using props. The child can also receive functions from the parent to update that state.
Click to reveal answer
intermediate
What is 'lifting state up' in React?
It means moving the shared state to the closest common parent of components that need it, so they can all access and update the same state.
Click to reveal answer
intermediate
Name a React hook commonly used to share state across many components without passing props deeply.
The useContext hook lets components access shared state from a context provider without passing props through every level.
Click to reveal answer
beginner
Why is it better to avoid duplicating state in multiple components?
Duplicating state can cause inconsistencies and bugs because changes in one place won’t update the others. Sharing state keeps data in sync everywhere.
Click to reveal answer
Which React feature helps share state without passing props through many components?
✗ Incorrect
The useContext hook allows components to access shared state from a context provider without prop drilling.
What does 'lifting state up' mean?
✗ Incorrect
Lifting state up means moving shared state to the nearest common parent so multiple components can access it.
If a parent component holds state and passes it to a child, how can the child update that state?
✗ Incorrect
The parent can pass a function to the child that updates the parent's state when called.
Why should you avoid duplicating state in multiple components?
✗ Incorrect
Duplicated state can get out of sync, causing bugs and inconsistent UI.
Which of these is NOT a way to share state between React components?
✗ Incorrect
Local variables inside components are not shared state; they are private to each component.
Explain how you would share a piece of state between two sibling components in React.
Think about where the state should live so both siblings can access it.
You got /3 concepts.
Describe the role of React Context and useContext hook in sharing state.
Imagine a shared storage accessible by many components.
You got /3 concepts.