@react-hookz/web
Version:
React hooks done right, for browser and SSR.
15 lines (14 loc) • 505 B
JavaScript
import { useEffect } from 'react';
import { useFirstMountState } from '..';
import { noop } from "../util/const.js";
/**
* 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 function useUpdateEffect(effect, deps) {
var isFirstMount = useFirstMountState();
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(isFirstMount ? noop : effect, deps);
}