@mantine/hooks
Version:
A collection of 50+ hooks for state and UI management
14 lines (13 loc) • 662 B
JavaScript
"use client";
const require_use_throttled_callback = require("../use-throttled-callback/use-throttled-callback.cjs");
let react = require("react");
//#region packages/@mantine/hooks/src/use-throttled-state/use-throttled-state.ts
function useThrottledState(defaultValue, wait) {
const [value, setValue] = (0, react.useState)(defaultValue);
const [setThrottledValue, clearTimeout] = require_use_throttled_callback.useThrottledCallbackWithClearTimeout(setValue, wait);
(0, react.useEffect)(() => clearTimeout, []);
return [value, setThrottledValue];
}
//#endregion
exports.useThrottledState = useThrottledState;
//# sourceMappingURL=use-throttled-state.cjs.map