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

A custom hook `usePrevious` is implemented as below and used to compare the current and previous value of a prop in the same render. On the very first render, and on a render where the value changed, what does `usePrevious(value)` return?

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