What is the diff useState
vs useRef
?
useState
causes components to re-render after state updates whereasuseRef
doesn’t cause a component to re-render when the value or state changes. Essentially,useRef
is like a “box” that can hold a mutable value in its (.current) property.useState
allows us to update the state inside components. WhileuseRef
allows referencing DOM elements.