@supunlakmal/hooks
Version:
A collection of reusable React hooks
15 lines • 590 B
JavaScript
import { useEffect } from 'react';
import { noop } from '../../util/const';
import { useFirstMountState } from '../state-management/useFirstMountState';
/**
* Effect hook that ignores the first render (not invoked on mount).
*
* @param effect Effector to run on updates
* @param deps Dependencies list, as for `useEffect` hook
*/
export const useUpdateEffect = (effect, deps) => {
const isFirstMount = useFirstMountState();
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(isFirstMount ? noop : effect, deps);
};
//# sourceMappingURL=useUpdateEffect.js.map