function Counter() { const [count, setCount] = useState(0); const prevCount = usePrevious(count); return

Now: {count}, before: {prevCount}

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