Imperative React

Learn about the use of useRef hook for imperative programming in React!

We'll cover the following

In a React function component, React’s useRef Hook is used mostly for imperative programming. Throughout React’s history, the ref and its usage had a few versions:

  • String Refs (deprecated)
  • Callback Refs
  • createRef Refs (exclusive for Class Components)
  • useRef Hook Refs (exclusive for Function Components)

Recently, the React team introduced React’s createRef as the latest equivalent to a function component’s useRef hook:

Get hands-on with 1400+ tech skills courses.