loading messages

This commit is contained in:
2025-10-06 11:27:02 +02:00
parent 35e8a0f6dc
commit fd416b5b05
9 changed files with 336 additions and 40 deletions
+27
View File
@@ -0,0 +1,27 @@
import { useCallback } from "react";
import { useGlobal } from "reactn";
const useGlobalLoading = () => {
const [, setIsLoading] = useGlobal("_isLoading");
const [, setLoadingMessage] = useGlobal("_loadingMessage");
const setLoading = useCallback(
async (loading, { message } = {}) => {
if (loading) {
await setLoadingMessage(message ?? null);
await setIsLoading(true);
} else {
await setIsLoading(false);
await setLoadingMessage(null);
}
},
[setIsLoading, setLoadingMessage]
);
return {
setLoading,
setLoadingMessage,
};
};
export default useGlobalLoading;