PromucFlow_constructor/app/client/src/utils/hooks/usePrevious.tsx
Rishabh Rathod 4e13fc5125
fix: AppViewer init and page fetch logic (#14294)
OnPageSwitch we need not `initializeAppViewPage` but instead, only `fetchPublishedPage` this changes fixes that.
2022-06-10 18:22:59 +00:00

13 lines
298 B
TypeScript

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;