diff --git a/src/components/ConnectionRequired.tsx b/src/components/ConnectionRequired.tsx index b9e83ddb0c..62e5f66113 100644 --- a/src/components/ConnectionRequired.tsx +++ b/src/components/ConnectionRequired.tsx @@ -3,7 +3,7 @@ import { Outlet, useNavigate } from 'react-router-dom'; import alert from './alert'; import { appRouter } from './appRouter'; -import loading from './loading/loading'; +import Loading from './loading/Loading'; import ServerConnections from './ServerConnections'; import globalize from '../scripts/globalize'; @@ -152,17 +152,8 @@ const ConnectionRequired: FunctionComponent = ({ validateConnection(); }, [ isAdminRequired, isUserRequired, navigate ]); - // Show/hide the loading indicator - useEffect(() => { - if (isLoading) { - loading.show(); - } else { - loading.hide(); - } - }, [ isLoading ]); - if (isLoading) { - return null; + return ; } return ; diff --git a/src/components/loading/Loading.tsx b/src/components/loading/Loading.tsx new file mode 100644 index 0000000000..ef8cae21a2 --- /dev/null +++ b/src/components/loading/Loading.tsx @@ -0,0 +1,17 @@ +import React, { FunctionComponent, useEffect } from 'react'; + +import loading from './loading'; + +const Loading: FunctionComponent = () => { + useEffect(() => { + loading.show(); + + return () => { + loading.hide(); + }; + }, []); + + return <>; +}; + +export default Loading;