1
- import React , { useEffect , useState } from "react" ;
1
+ import React from "react" ;
2
2
import { Route , Redirect } from "react-router-dom" ;
3
3
4
- import { IonApp , IonSpinner , IonRouterOutlet } from "@ionic/react" ;
4
+ import { IonApp , IonRouterOutlet , IonLoading } from "@ionic/react" ;
5
5
import { IonReactRouter } from "@ionic/react-router" ;
6
6
7
7
import HomePage from "./pages/HomePage" ;
8
8
import LoginPage from "./pages/LoginPage" ;
9
9
import RegistrationPage from "./pages/RegistrationPage" ;
10
10
11
11
import { observer , MobXProviderContext } from "mobx-react" ;
12
- import { autorun } from "mobx" ;
13
12
14
13
const PrivateRoutes = ( ) => {
15
14
return (
@@ -34,28 +33,13 @@ const PublicRoutes = () => {
34
33
35
34
const App = ( ) => {
36
35
const { store } = React . useContext ( MobXProviderContext ) ;
37
- const [ hasUser , setHasUser ] = useState ( false ) ;
38
- useEffect ( ( ) => {
39
- autorun ( ( ) => {
40
- setHasUser ( store . authenticatedUser !== null ) ;
41
- } ) ;
42
- } , [ store . authenticatedUser ] ) ;
43
-
44
- console . log ( hasUser ) ;
45
36
46
37
return ! store . authCheckComplete ? (
47
- < div
48
- style = { {
49
- position : "absolute" ,
50
- left : "50%" ,
51
- top : "50%" ,
52
- transform : "translate(-50%, -50%)" ,
53
- } }
54
- >
55
- < IonSpinner name = "circles" />
56
- </ div >
38
+ < IonApp >
39
+ < IonLoading message = "Starting App..." />
40
+ </ IonApp >
57
41
) : (
58
- < IonApp > { hasUser ? < PublicRoutes /> : < PrivateRoutes /> } </ IonApp >
42
+ < IonApp > { store . authenticatedUser ? < PublicRoutes /> : < PrivateRoutes /> } </ IonApp >
59
43
) ;
60
44
} ;
61
45
0 commit comments