InterviewStack.io LogoInterviewStack.io

React Functional Components and Hooks Questions

Focuses on the functional component model and React hooks API. Topics include using state with useState, managing side effects and lifecycle with useEffect including dependency arrays and cleanup, avoiding common pitfalls such as stale closures and infinite loops, memoization and performance patterns with useMemo and useCallback, state management with useReducer, context consumption with useContext, building and testing custom hooks, rules of hooks, and common patterns for data fetching, event handling, and component local state. Emphasis spans from junior correct usage to advanced patterns and debugging of hooks.

MediumTechnical
30 practiced
You have a Timer component that uses useEffect to run setInterval every second and logs the current count. A naive implementation logs stale values due to closures. In React (JavaScript), show the incorrect approach and then implement two correct fixes: (1) use a functional state update inside the interval, and (2) use a ref to always read the latest value inside the interval. Explain pros and cons of each solution.
EasyTechnical
53 practiced
Implement a counter using useReducer in a functional React component. The reducer should support actions: 'increment', 'decrement', 'reset', and 'increment-by' with a payload amount. Provide the reducer, useReducer setup, and dispatch examples. Explain when useReducer is preferable to multiple useState calls.
MediumTechnical
27 practiced
You're building a complex multi-field form with nested objects and validation rules. Describe and implement (in JavaScript/React) how you would structure state and actions with useReducer to handle field updates, synchronous validation, async validation, and submission states. Explain advantages compared to managing many separate useState hooks.
EasyTechnical
31 practiced
Explain the Rules of Hooks in React for functional components. Describe why hooks must be called unconditionally and only at the top level of a component (or from other hooks), and give at least two concrete examples of incorrect hook usage and the problems they cause.
MediumTechnical
56 practiced
Implement a custom hook useDebounce(value, delay) that returns the debounced version of value, updating only after the delay milliseconds have passed without changes. Include cleanup to cancel timers when value or delay changes and provide a TypeScript function signature for the hook.

Unlock Full Question Bank

Get access to hundreds of React Functional Components and Hooks interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.