What is useRef used for in React?

Updated May 6, 2026

Short answer

useRef stores mutable values that persist without causing re-renders.

Deep explanation

It returns a ref object with a .current property. It is useful for accessing DOM elements or storing mutable values.

Real-world example

Focusing an input field programmatically.

Common mistakes

  • Using useRef for reactive state instead of useState.

Follow-up questions

  • Does changing useRef trigger re-render?
  • When should useRef be preferred over state?

More React Hooks interview questions

View all →