mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
Merge pull request #556 from mitchheddles/patch-1
Removed prepended window from setTimeout
This commit is contained in:
commit
c73e92fbb5
@ -4,12 +4,12 @@ export type UseTimeoutFnReturn = [() => boolean | null, () => void, () => void];
|
||||
|
||||
export default function useTimeoutFn(fn: Function, ms: number = 0): UseTimeoutFnReturn {
|
||||
const ready = useRef<boolean | null>(false);
|
||||
const timeout = useRef(0);
|
||||
const timeout = useRef<ReturnType<typeof setTimeout>>();
|
||||
|
||||
const isReady = useCallback(() => ready.current, []);
|
||||
const set = useCallback(() => {
|
||||
ready.current = false;
|
||||
timeout.current = window.setTimeout(() => {
|
||||
timeout.current = setTimeout(() => {
|
||||
ready.current = true;
|
||||
fn();
|
||||
}, ms);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user