From 7ef1b086bd61012cb681885638058c4debff356a Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sat, 30 May 2020 22:31:12 +0200 Subject: [PATCH] Make application loader only trigger once Signed-off-by: Tilman Vatteroth --- src/components/application-loader/application-loader.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/application-loader/application-loader.tsx b/src/components/application-loader/application-loader.tsx index b2ea55e60..f81a8666a 100644 --- a/src/components/application-loader/application-loader.tsx +++ b/src/components/application-loader/application-loader.tsx @@ -10,6 +10,7 @@ export const ApplicationLoader: React.FC = ({ children }) => { const [doneTasks, setDoneTasks] = useState(0) const [initTasks, setInitTasks] = useState([]) const { pathname } = useLocation() + const [applicationLoading, setApplicationLoading] = useState(false) const runTask = async (task: Promise): Promise => { await task @@ -19,10 +20,14 @@ export const ApplicationLoader: React.FC = ({ children }) => { } useEffect(() => { + if (applicationLoading) { + return + } + setApplicationLoading(true) const baseUrl:string = window.location.pathname.replace(pathname, '') + '/' console.debug('Base URL is', baseUrl) setInitTasks(setUp(baseUrl)) - }, [pathname]) + }, [applicationLoading, pathname]) useEffect(() => { for (const task of initTasks) {