@mantine/hooks
Version:
A collection of 50+ hooks for state and UI management
1 lines • 880 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,aAAa;CAEhD,MAAM,CAAC,mBAAmB,gBAAgBA,+BAAAA,qCAAqC,UAAU,KAAK;AAE9F,EAAA,GAAA,MAAA,iBAAgB,cAAc,EAAE,CAAC;AAEjC,QAAO,CAAC,OAAO,kBAAkB"}