Switch to workspace

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-08-28 12:46:03 +02:00
parent 694abcb489
commit 4d5690d0c1
1318 changed files with 12005 additions and 11618 deletions

View File

@@ -0,0 +1,19 @@
import { useState } from 'react';
const useLoading = (initialState: boolean = false) => {
const [isLoading, setIsLoading] = useState<boolean>(initialState);
const setPromise = <T>(promise: Promise<T>) => {
setIsLoading(true);
promise
.then(() => setIsLoading(false))
.catch(() => setIsLoading(false));
return promise;
};
return [isLoading, setPromise] as const;
};
export { useLoading };