Interview Q&A / React

INTERVIEW Q&A · 58 QUESTIONS

React interview questions

Rendering, state, hooks, keys and effects, explained with small examples.

  1. What does React.memo do, and when does it fail to help?

    React.memo wraps a component so React skips re-rendering it when its props are shallowly equal to the last render. It fails when you pass new object, array or function references on every parent render.

    IntermediateQuick answer1 min read
  2. Why does useCallback often do nothing unless the child is wrapped in React.memo?

    useCallback keeps a function reference stable, but a child still re-renders whenever its parent does unless the child is wrapped in React.memo or the function is a hook dependency. The stable reference only helps where something compares it.

    IntermediateQuick answer1 min read