InterviewStack.io LogoInterviewStack.io

Component State Management Questions

Covers approaches and patterns for managing user interface state within component-based front end frameworks such as React and Angular. Topics include local component state, lifting state up, one way data flow, controlled versus uncontrolled components, prop passing and change handling, avoiding stale closures and missing dependency arrays, component composition patterns, performance considerations to prevent unnecessary re renders, and when to choose built in mechanisms versus external state libraries. For React this includes hooks such as useState, useContext, useReducer, useCallback, and useMemo and the trade offs of Context versus external stores. For Angular this includes using components and services, dependency injection, reactive programming patterns with observable streams, and change detection strategies. Candidates may be asked to compare state architectures, justify trade offs between simplicity and scalability, refactor components to improve state locality and performance, and design data flow for a feature from user interaction to persistent update.

EasyTechnical
67 practiced
What is a stale closure in the context of React hooks? Provide a concise example (in JavaScript using useEffect or an event handler) showing how a closure can capture outdated state and list two practical ways to avoid this problem in component code.
HardTechnical
66 practiced
You are a frontend lead. The codebase started with localized component state but is becoming hard to maintain as features grow. Draft a plan to evaluate, propose, and lead a migration to an external state library. Include evaluation criteria (developer velocity, performance, debugging), a pilot/proof-of-concept approach, incremental migration strategies, rollback plans, and success metrics for stakeholders.
MediumTechnical
74 practiced
Design keyboard navigation state for a custom tabs component. Requirements: arrow-key navigation, Home/End shortcuts, roving tabindex for accessibility, focus management, and ARIA attributes. Describe the state you would keep (e.g., focusedIndex, activeIndex), the event handlers, and how to minimize re-renders when tabs change.
MediumTechnical
63 practiced
Examine this React component:
javascript
function Counter() {
  const [count, setCount] = useState(0);
  useEffect(() => {
    const id = setInterval(() => {
      console.log('count:', count);
      setCount(count + 1);
    }, 1000);
    return () => clearInterval(id);
  }, []);
  return <div>{count}</div>;
}
Identify the bug that prevents the counter from incrementing as expected, explain why it happens (stale closure), and refactor the component to fix the issue using a functional update or a ref.
MediumTechnical
55 practiced
Explain how React.memo, useMemo, and useCallback help prevent unnecessary re-renders. Provide concrete examples of common pitfalls—such as recreating objects/arrays inline, missing dependency arrays, and stale closures—and show how to fix them.

Unlock Full Question Bank

Get access to hundreds of Component State Management interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.