diff --git a/src/frontend/src/hooks/usePrevious.ts b/src/frontend/src/hooks/usePrevious.ts new file mode 100644 index 00000000..ff79f7e9 --- /dev/null +++ b/src/frontend/src/hooks/usePrevious.ts @@ -0,0 +1,9 @@ +import { useEffect, useRef } from 'react' + +export const usePrevious = (value: T): T | undefined => { + const ref = useRef() + useEffect(() => { + ref.current = value + }, [value]) + return ref.current +}