Q11: What is the useRef hook and what are its main use cases?

useRef returns a mutable object whose .current property persists across re-renders without causing a component re-render when mutated. Common uses include storing DOM element references and holding instance values.

Key Takeaways
  • Mutating ref.current does NOT trigger a component re-render.

  • Used to access underlying real DOM nodes or store persistent non-rendering values.

Knowledge Check

What happens to the component UI when the .current property of a useRef object changes?