Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Checkout Widgets types change for useInterval hook #1096

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/checkout/widgets-lib/src/lib/hooks/useInterval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect, useRef } from 'react';
// Inspired by https://usehooks-ts.com/react-hook/use-interval
export function useInterval(callback: () => void, delay: number | null): () => void {
const savedCallback = useRef(callback);
const interval = useRef<NodeJS.Timer | null>(null);
const interval = useRef<number>(0);

// Remember the latest callback if it changes.
useBrowserLayoutEffect(() => {
Expand All @@ -18,10 +18,10 @@ export function useInterval(callback: () => void, delay: number | null): () => v
return;
}

interval.current = setInterval(() => savedCallback.current(), delay);
interval.current = setInterval(() => savedCallback.current(), delay) as unknown as number;

// eslint-disable-next-line consistent-return
return () => { clearInterval(interval.current as NodeJS.Timer); };
return () => { clearInterval(interval.current); };
}, [delay]);

return () => {
Expand Down