How is useRef different from a plain JavaScript variable?

A plain JavaScript variable resets its value on every render of the component.

useRef persists its value across renders.