Interview Q&A / React

INTERVIEW Q&A · 58 QUESTIONS

React interview questions

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

  1. How would you write a useDebounce hook for a search box?

    Keep a debounced copy of the value in state. In an effect, start a setTimeout that updates the copy after a delay, and clear that timer in the cleanup so only the last change within the delay goes through.

    IntermediateQuick answer1 min read