Engineering Decisions · Junior · Question 5 of 12
Two sibling components on one page share a filter value: one edits it, the other shows the filtered table. Nothing else needs it. Where does the state go?
- 1In a global store such as Zustand or Redux
- 2In a Context provider at the root of the app
- 3In their closest common parent, passed via props
Show the answer
Correct answer: In their closest common parent, passed via props
Explanation
Lifting state to the closest common parent is enough for two siblings and keeps the data flow easy to follow. Context fits values needed by many components at different depths, such as a theme. A global store fits state shared across distant pages, and adding one for a single filter is more machinery than the task needs.