Skip to content

The open alternative to Salesforce, designed for AI.

414 B
Raw Blame
import { type DependencyList, type EffectCallback, useEffect } from 'react';

import { useFirstMountState } from './useFirstMountState';

export const useUpdateEffect = (
  effect: EffectCallback,
  deps?: DependencyList,
) => {
  const isFirst = useFirstMountState();

  useEffect(() => {
    if (!isFirst) {
      return effect();
    }
    // oxlint-disable-next-line react-hooks/exhaustive-deps
  }, deps);
};