useRef returns the same object on subsequent renders, so the value stored in ref.current persists until your code or React changes it.