useRef

Learn how to persist the value of a reference between components' re-renderings and update a reference without triggering a re-render.

We'll cover the following

What is useRef()?

The useRef() Hook is used to create references by using a dedicated Hook. We’ll call it in the following way:

const ref = useRef(initialValue);

Code Example

Let’s look at an example:

Get hands-on with 1200+ tech skills courses.