Answers for "useRef for diffing"

0

useRef for diffing

function usePrevious(value) {
  const ref = useRef();
  useEffect(() => {
    ref.current = value;
  });
  return ref.current;
}
Posted by: Guest on November-11-2020

Browse Popular Code Answers by Language