@mantine/hooks
Version:
A collection of 50+ hooks for state and UI management
1 lines • 886 B
Source Map (JSON)
{"version":3,"file":"use-throttled-state.cjs","names":["useThrottledCallbackWithClearTimeout"],"sources":["../../src/use-throttled-state/use-throttled-state.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useThrottledCallbackWithClearTimeout } from '../use-throttled-callback/use-throttled-callback';\n\nexport function useThrottledState<T = any>(defaultValue: T, wait: number) {\n const [value, setValue] = useState(defaultValue);\n\n const [setThrottledValue, clearTimeout] = useThrottledCallbackWithClearTimeout(setValue, wait);\n\n useEffect(() => clearTimeout, []);\n\n return [value, setThrottledValue] as const;\n}\n"],"mappings":";;;;AAGA,SAAgB,kBAA2B,cAAiB,MAAc;CACxE,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAAqB,YAAY;CAE/C,MAAM,CAAC,mBAAmB,gBAAgBA,+BAAAA,qCAAqC,UAAU,IAAI;CAE7F,CAAA,GAAA,MAAA,iBAAgB,cAAc,CAAC,CAAC;CAEhC,OAAO,CAAC,OAAO,iBAAiB;AAClC"}