Files
pterodactyl-panel/resources/scripts/plugins/useDebouncedValue.ts
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

16 lines
404 B
TypeScript

import { useEffect, useState } from 'react';
export const useDebouncedValue = <T>(value: T, delay: number): T => {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const timeout = setTimeout(() => {
setDebouncedValue(value);
}, delay);
return () => clearTimeout(timeout);
}, [delay, value]);
return debouncedValue;
};