Tsallaka zuwa abun ciki
Justice Tech School

useRef

useRef holds a mutable value that does not trigger renders and can point to a DOM node.

Example
function Focus() {
  const ref = useRef(null);
  return (
    <>
      <input ref={ref} />
      <button onClick={() => ref.current.focus()}>Focus</button>
    </>
  );
}

Exercise

Read the ref.

ref.

Quiz Test

Does changing ref.current re-render?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.