function usePrevious(value) { const ref = useRef(); useEffect(() => { ref.current = value; }, [value]); return ref.current; } function Counter() { const [count, setCount] = useState(0); const previousCount = usePrevious(count); return (

Actuel : {count}

Précédent : {previousCount}

); }