mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
14 lines
276 B
TypeScript
14 lines
276 B
TypeScript
import shim from '../shim';
|
|
|
|
const { useRef, useEffect } = shim.react();
|
|
|
|
const usePrevious = <T> (value: T, initialValue: T = null) => {
|
|
const ref = useRef<T>(initialValue);
|
|
useEffect(() => {
|
|
ref.current = value;
|
|
});
|
|
return ref.current;
|
|
};
|
|
|
|
export default usePrevious;
|