You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
189 B
10 lines
189 B
4 years ago
|
import { useEffect, useRef } from 'react';
|
||
4 years ago
|
|
||
4 years ago
|
export function usePrevious(value) {
|
||
4 years ago
|
const ref = useRef();
|
||
4 years ago
|
useEffect(() => {
|
||
4 years ago
|
ref.current = value;
|
||
|
}, [value]);
|
||
|
return ref.current;
|
||
4 years ago
|
}
|