15 lines
393 B
TypeScript
15 lines
393 B
TypeScript
import { DependencyList, EffectCallback, useEffect } from 'react';
|
|
|
|
import { useFirstMountState } from './useFirstMountState';
|
|
|
|
export function useUpdateEffect(effect: EffectCallback, deps?: DependencyList) {
|
|
const isFirst = useFirstMountState();
|
|
|
|
useEffect(() => {
|
|
if (!isFirst) {
|
|
return effect();
|
|
}
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, deps);
|
|
}
|