Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumReactcustom hooksSingle-choice MCQ

A team writes a custom hook usePrevious(value) to track a value from the previous render. Which implementation is correct, and why does it return the previous (not current) value?

function usePrevious(value) { const ref = useRef(); useEffect(() => { ref.current = value; }); return ref.current; }