PromucFlow_constructor/app/client/src/utils/hooks/usePrevious.tsx

13 lines
298 B
TypeScript
Raw Normal View History

import { useEffect, useRef } from "react";
// Make sure to use this hook at the start of functional component
const usePrevious = <T,>(value: T): T | undefined => {
const ref = useRef<T>();
useEffect(() => {
ref.current = value;
});
return ref.current;
};
export default usePrevious;