Migrate to a monorepo structure (#2909)
This commit is contained in:
17
packages/twenty-front/src/hooks/useUpdateEffect.ts
Normal file
17
packages/twenty-front/src/hooks/useUpdateEffect.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { DependencyList, EffectCallback, useEffect } from 'react';
|
||||
|
||||
import { useFirstMountState } from './useFirstMountState';
|
||||
|
||||
export const useUpdateEffect = (
|
||||
effect: EffectCallback,
|
||||
deps?: DependencyList,
|
||||
) => {
|
||||
const isFirst = useFirstMountState();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isFirst) {
|
||||
return effect();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, deps);
|
||||
};
|
||||
Reference in New Issue
Block a user