Small fix in monitoring and useAsync

This commit is contained in:
2026-01-03 04:06:31 +01:00
parent 6914b97faf
commit 5e84c05bc7
2 changed files with 16 additions and 41 deletions
+6 -2
View File
@@ -44,7 +44,7 @@ export function useAsyncInterval<T>(
useEffect(() => {
let isMounted = true;
const iid = setInterval(() => {
const run = () => {
setLoading(true);
asyncFunction()
.then((result) => {
@@ -56,7 +56,11 @@ export function useAsyncInterval<T>(
.finally(() => {
if (isMounted) setLoading(false);
});
}, interval);
};
const iid = setInterval(run, interval);
run();
return () => {
isMounted = false;