mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
formatting
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user