useMemo is a hint and not a guarantee

React may discard memoised values to free memory, so useMemo is a performance optimisation and never a correctness mechanism.

// fine: an expensive derivation
const sorted = useMemo(() => rows.slice().sort(cmp), [rows])

// NOT fine: relying on the identity being stable forever
const id = useMemo(() => crypto.randomUUID(), [])
// → use useRef, or useId in a later version

// and the cost: the comparison, the closure and the
// array are allocated on every render regardless.

The documentation is explicit that a future version may forget memoised values between renders, which turns a useMemo used for identity into an intermittent bug. For a value that must never change, useRef is the honest tool. The other half of this is that memoising something cheap is a net loss — the dependency comparison and the extra allocation cost more than recomputing a small object.