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