react-use/src/useUpdateEffect.ts
2020-02-04 07:12:19 +05:30

16 lines
346 B
TypeScript

/* eslint-disable */
import { useEffect } from 'react';
import { useFirstMountState } from './useFirstMountState';
const useUpdateEffect: typeof useEffect = (effect, deps) => {
const isFirstMount = useFirstMountState();
useEffect(() => {
if (!isFirstMount) {
return effect();
}
}, deps);
};
export default useUpdateEffect;