Intermediate Interview Questions
What is props drilling and how do you avoid it?
Passing props through components that do not use them to reach a deep child. Avoid with component composition (pass children), the Context API, or a state library such as Redux Toolkit or Zustand.
What is a Higher Order Component?
A function that takes a component and returns a new component with extra behaviour, e.g. withAuth(Dashboard). Custom hooks are now preferred for sharing logic; React.memo is a built-in HOC.
What was event pooling?
In React 16 synthetic event objects were reused: after the handler finished their properties were set to null, so async code needed e.persist(). React 17 removed pooling; events can be used any time.
Debouncing vs throttling?
Debounce runs a function once after activity stops for N ms (search input). Throttle runs it at most once every N ms while activity continues (scroll handler).
What causes memory leaks in React?
Timers, event listeners, subscriptions or requests that keep running after a component unmounts. Fix by returning a cleanup function from useEffect (clearInterval, removeEventListener, unsubscribe, AbortController.abort).
How does React batch state updates?
Since React 18, multiple setState calls in the same event handler, timeout or promise are batched into a single re-render (automatic batching).
Context API vs Redux?
Context is built in and good for rarely changing global data (theme, auth). Redux Toolkit suits large, frequently updated shared state with DevTools, middleware and selective re-renders.