-
-
Save Nilanth/4e47b87aea7061c81cd069d25744c8d7 to your computer and use it in GitHub Desktop.
App.js file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { lazy, Suspense } from 'react'; | |
import { | |
BrowserRouter as Router, | |
Switch, | |
Route, | |
Redirect | |
} from 'react-router-dom'; | |
import Loader from 'shareComponent/Loader'; | |
import ProtectedRoutes from 'routes/ProtectedRoutes'; //Authenticated routes | |
import PublicRoute from 'routes/PublicRoute'; | |
import PrivateRoute from 'routes/PrivateRoute'; | |
const LoginPage = lazy(() => import('components/LoginPage')); | |
const Register = lazy(() => import('components/Register')); | |
const ForgotPassword = lazy(() => import('components/ForgotPassword')); | |
const NoFoundComponent = lazy(() => import('components/NoFoundComponent')); | |
const App = () => { | |
const isAuthenticated = getToken(); | |
return ( | |
<Router> | |
<Suspense fallback={<Loader />}> | |
<Switch> | |
<PublicRoute | |
path="/login" | |
isAuthenticated={isAuthenticated} | |
> | |
<LoginPage /> | |
</PublicRoute> | |
<PublicRoute | |
path="/register" | |
isAuthenticated={isAuthenticated} | |
> | |
<Register /> | |
</PublicRoute> | |
<PublicRoute | |
path="/forgot-password" | |
isAuthenticated={isAuthenticated} | |
> | |
<ForgotPassword /> | |
</PublicRoute> | |
<PrivateRoute | |
path="/" | |
isAuthenticated={isAuthenticated} | |
> | |
<ProtectedRoutes /> | |
</PrivateRoute> | |
<Route path="*"> | |
<NoFoundComponent /> | |
</Route> | |
</Switch> | |
</Suspense> | |
</Router> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment