The useRef hook preserves the reference to the DOM element across re-renders, allowing you to access and manipulate it without causing unnecessary updates to the component.