mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
16 lines
404 B
TypeScript
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;
|
|
};
|