useRef() is a React hook that returns a mutable ref object. A ref is a way to store a value that persists between renders and is not part of the component state. Unlike the state, changes to a ref do not trigger a re-render of the component.
useRef Hook allows you to persist values between renders.
It can be used to store a mutable value that does not cause a re-render when updated.
It can be used to access a DOM element directly.
useRef() only returns one item. It returns an Object called current.
const count = useRef(0);
Download
0 formats
No download links available.
Part 47 React Tutorial | React Hooks | useRef hook | Timer task | UnControlled Way | NatokHD