use-did-update

Calls function in useEffect when value changes, but not when component mounts

Import

Usage

use-did-update hook works the same way as useEffect but it is not called when component is mounted:

import { useDidUpdate } from '@mantine/hooks';

function Demo() {
  useDidUpdate(() => console.log("Won't be called when mounted"), [value]);
}

Definition

function useDidUpdate(fn: EffectCallback, dependencies?: any[]): void;