mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-28 10:10:59 +00:00
14 lines
524 B
JavaScript
14 lines
524 B
JavaScript
'use client';
|
|
import { useState, useEffect } from 'react';
|
|
import { useThrottledCallbackWithClearTimeout } from '../use-throttled-callback/use-throttled-callback.mjs';
|
|
|
|
function useThrottledState(defaultValue, wait) {
|
|
const [value, setValue] = useState(defaultValue);
|
|
const [setThrottledValue, clearTimeout] = useThrottledCallbackWithClearTimeout(setValue, wait);
|
|
useEffect(() => clearTimeout, []);
|
|
return [value, setThrottledValue];
|
|
}
|
|
|
|
export { useThrottledState };
|
|
//# sourceMappingURL=use-throttled-state.mjs.map
|