mirror of
https://github.com/streamich/react-use.git
synced 2026-02-01 14:37:31 +00:00
Improve useThrottleFn type definition
This commit is contained in:
parent
e88f0ceb8a
commit
664b071d2d
@ -1,7 +1,7 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import useUnmount from './useUnmount';
|
||||
|
||||
const useThrottleFn = <T>(fn: (...args: any[]) => T, ms: number = 200, args: any[]) => {
|
||||
const useThrottleFn = <T, U extends any[]>(fn: (...args: U) => T, ms: number = 200, args: U) => {
|
||||
const [state, setState] = useState<T>(null as any);
|
||||
const timeout = useRef<ReturnType<typeof setTimeout>>();
|
||||
const nextArgs = useRef(null) as any;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user