@mantine/hooks
Version:
A collection of 50+ hooks for state and UI management
1 lines • 809 B
Source Map (JSON)
{"version":3,"file":"use-did-update.cjs","names":[],"sources":["../../src/use-did-update/use-did-update.ts"],"sourcesContent":["import { DependencyList, EffectCallback, useEffect, useRef } from 'react';\n\nexport function useDidUpdate(fn: EffectCallback, dependencies?: DependencyList) {\n const mounted = useRef(false);\n\n useEffect(\n () => () => {\n mounted.current = false;\n },\n []\n );\n\n useEffect(() => {\n if (mounted.current) {\n return fn();\n }\n\n mounted.current = true;\n return undefined;\n }, dependencies);\n}\n"],"mappings":";;;AAEA,SAAgB,aAAa,IAAoB,cAA+B;CAC9E,MAAM,WAAA,GAAA,MAAA,QAAiB,KAAK;CAE5B,CAAA,GAAA,MAAA,uBACc;EACV,QAAQ,UAAU;CACpB,GACA,CAAC,CACH;CAEA,CAAA,GAAA,MAAA,iBAAgB;EACd,IAAI,QAAQ,SACV,OAAO,GAAG;EAGZ,QAAQ,UAAU;CAEpB,GAAG,YAAY;AACjB"}