useRefreturns a mutable ref object whose
.currentproperty is initialized to the passed argument (
initialValue). The returned object will persist for the full lifetime of the component.
useRefdoesn’t notify you when its content changes. Mutating the
.currentproperty doesn’t cause a re-render. If you want to run some code when React attaches or detaches a ref to a DOM node, you may want to use a callback ref instead.