1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-01 21:52:19 +01:00
2022-12-21 14:12:13 +01:00

12 lines
330 B
TypeScript

import { useEffect, useRef } from 'react';
// provides the previous value of a Prop, in a useEffect hook
// Credits to: https://stackoverflow.com/a/57706747/1039377
export const usePrevious = <T>(value: T): T | undefined => {
const ref = useRef<T>();
useEffect(() => {
ref.current = value;
});
return ref.current;
};