Reference a DOM node.
Section: Context and Ref Hooks
useRef DOM reference
tsx
tsx
const inputRef = useRef<HTMLInputElement | null>(null);
inputRef.current?.focus();Explanation
Refs are useful for DOM access, timers, imperative APIs, or mutable values that do not trigger re-renders.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Context and Ref Hooks
useRef mutable container
Persist mutable values between renders without re-rendering.
useImperativeHandle custom ref API
Expose a controlled imperative API to a parent ref.
useId for stable accessible IDs
Generate stable IDs for labels and ARIA relationships.