12 lines
199 B
JavaScript
12 lines
199 B
JavaScript
|
import { useEffect, useRef } from 'react';
|
||
|
|
||
|
export default function usePrevious(value) {
|
||
|
const ref = useRef();
|
||
|
|
||
|
useEffect(() => {
|
||
|
ref.current = value;
|
||
|
}, [value]);
|
||
|
|
||
|
return ref.current;
|
||
|
}
|