How do you decide whether a piece of state should live locally in a component or be shared more globally?

technical-conceptual · Junior level · software-engineering

What the interviewer is really asking

Tests judgment about scoping state to the smallest place that needs it and lifting or sharing it only when multiple components genuinely depend on it.

What to say

What to avoid

Example answers

Strong: My default is to keep state local, in the component that uses it, so re-renders stay contained and the component is easy to follow. Once two sibling components need the same value, I lift it up to their closest common parent and pass it down. For things that are genuinely app-wide and change rarely, like the current user or the theme, I'll put it in context. But I don't make everything global by default, because that creates extra re-renders and indirection for state that only one component cares about.

Weak: I usually just put state in a global store like Redux so any component can grab it if it needs it later. That way I don't have to pass props around or lift things up.

Want questions matched to your role? Paste a job title, job description, or CV and get a personalized set, or go Pro to unlock the full bank.