`useRef` holds a mutable `.current` value that survives re-renders without causing one when changed — used for timers, previous values, or references to native components.
import { useRef, useEffect } from "react";
function usePrevious<T>(value: T): T | undefined {
const ref = useRef<T>();
useEffect(() => { ref.current = value; }, [value]);
return ref.current;
}Refs are also how you imperatively call methods on native components, e.g. `inputRef.current?.focus()` on a `TextInput` after a modal opens.