R:
Size: a a a
R:
MK
MK
AM
AP
obj: {[prop: string]: any}
AM
obj: {[prop: string]: any}
РФ
РФ
РФ
EC
V
_param
ТФ
EG
_param
V
V
function useHook(func, delay) {
return React.useMemo(
(...args), func
)
}
V
export function useDebounce(func: any, delay: number) {
const [id, setId] = useState<NodeJS.Timeout | null>(null);
return useMemo(
(...args) => {
if (id) {
clearTimeout(id);
} else {
setId(
setTimeout(() => {
setId(null);
func(...args);
}, delay)
);
}
},
[func]
);
}
Ф
export function useDebounce(func: any, delay: number) {
const [id, setId] = useState<NodeJS.Timeout | null>(null);
return useMemo(
(...args) => {
if (id) {
clearTimeout(id);
} else {
setId(
setTimeout(() => {
setId(null);
func(...args);
}, delay)
);
}
},
[func]
);
}
V