mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
11 lines
326 B
TypeScript
11 lines
326 B
TypeScript
import { useEffect, useRef } from 'react';
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
|
export default function usePrevious<T>(value: T, initialValue: T = null): T {
|
|
const ref = useRef(initialValue);
|
|
useEffect(() => {
|
|
ref.current = value;
|
|
});
|
|
return ref.current;
|
|
}
|