← BYTES
React.js·Intermediate·Ref: 4.2.10

What is a basic, legitimate use case for `useRef` at this stage?

Have a question about this video? Mention reference 4.2.10 when you contact us.

a.Storing state that should trigger a re-render whenever it changes
b.Replacing props entirely
c.Getting direct access to a real DOM node, e.g. to call `.focus()` on an input imperatively
d.Fetching data from an API
Attaching a ref (via the `ref` prop) to a JSX element gives you a `.current` handle to the actual underlying DOM node once it's mounted, which is useful for imperative actions the declarative render model doesn't cover, like focusing an input or measuring an element's size.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES4210#Reactjs