1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/app-desktop/gui/hooks/usePrevious.ts
2024-11-10 14:04:46 +00:00

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;
}