arrow_backBACK TO DRILLS
Black BeltuserefPREMIUM
useState as a Callback Ref to Trigger Effects on DOM Availability
A developer needs an effect to run the moment a DOM node becomes available, but the node is attached via useRef(null). Why does assigning a useState setter directly as the ref prop (e.g. <div ref={setNode}/>) solve this, when a plain ref object does not?