formatting

This commit is contained in:
proddy
2024-10-13 22:45:12 +01:00
parent 3c1bfa0f3e
commit e71542d9aa

View File

@@ -4,9 +4,11 @@ import { useEffect, useRef } from 'react';
export const useInterval = (callback: () => void, delay: number) => {
const intervalRef = useRef<number | null>(null);
const savedCallback = useRef<() => void>(callback);
useEffect(() => {
savedCallback.current = callback;
}, [callback]);
useEffect(() => {
const tick = () => savedCallback.current();
if (typeof delay === 'number') {
@@ -18,5 +20,6 @@ export const useInterval = (callback: () => void, delay: number) => {
};
}
}, [delay]);
return intervalRef;
};