|
1 | 1 | import React, { useState, useEffect } from 'react'
|
2 |
| -import { Route, Switch, Redirect } from 'react-router' |
| 2 | +import { Route, Routes, Navigate } from 'react-router-dom' |
3 | 3 | import { useSelector } from 'react-redux'
|
4 | 4 |
|
5 | 5 | // ----------- Pages Imports ---------------
|
@@ -34,51 +34,52 @@ export const RoutedContent = () => {
|
34 | 34 | }, [])
|
35 | 35 |
|
36 | 36 | return (
|
37 |
| - <Switch> |
38 |
| - <Redirect from="/" to="/home/dashboard" exact /> |
39 |
| - <Route path="/home/dashboard" exact component={DashboardPage} /> |
40 |
| - <Route path="/home/health" exact component={HealthPage} /> |
41 |
| - <Route path="/home/licenseDetails" exact component={LicenseDetailsPage} /> |
| 37 | + <Routes> |
| 38 | + <Route path="/home/dashboard" element={<DashboardPage />} /> |
| 39 | + <Route path="/" element={ <Navigate to="/home/dashboard" /> } /> |
| 40 | + <Route path="/home/health" element={<HealthPage />} /> |
| 41 | + <Route path="/home/licenseDetails" element={<LicenseDetailsPage />} /> |
42 | 42 | {/* Layouts */}
|
43 |
| - <Route path="/layouts/navbar" component={NavbarOnly} /> |
44 |
| - <Route path="/layouts/sidebar" component={SidebarDefault} /> |
45 |
| - <Route path="/layouts/sidebar-a" component={SidebarA} /> |
| 43 | + <Route path="/layouts/navbar" element={<NavbarOnly />} /> |
| 44 | + <Route path="/layouts/sidebar" element={<SidebarDefault />} /> |
| 45 | + <Route path="/layouts/sidebar-a" element={<SidebarA />} /> |
46 | 46 | <Route
|
47 | 47 | path="/layouts/sidebar-with-navbar"
|
48 |
| - component={SidebarWithNavbar} |
| 48 | + element={<SidebarWithNavbar />} |
49 | 49 | />
|
50 | 50 |
|
51 | 51 | {/* -------- Plugins ---------*/}
|
52 | 52 | {pluginMenus.map(
|
53 | 53 | (item, key) =>
|
54 | 54 | hasPermission(scopes, item.permission) && (
|
55 |
| - <Route key={key} path={item.path} component={item.component} /> |
| 55 | + <Route key={key} path={item.path} element={<item.component />} /> |
56 | 56 | ),
|
57 | 57 | )}
|
58 | 58 | {/* Pages Routes */}
|
59 |
| - <Route component={ProfilePage} path="/profile" /> |
60 |
| - <Route component={ByeBye} path="/logout" /> |
61 |
| - <Route component={Gluu404Error} path="/error-404" /> |
| 59 | + <Route element={<ProfilePage />} path="/profile" /> |
| 60 | + <Route element={<ByeBye />} path="/logout" /> |
| 61 | + <Route element={<Gluu404Error />} path="/error-404" /> |
62 | 62 |
|
63 | 63 | {/* 404 */}
|
64 |
| - <Redirect to="/error-404" /> |
65 |
| - </Switch> |
| 64 | + <Route path="*" element={ <Navigate to="/error-404" /> } /> |
| 65 | + </Routes> |
66 | 66 | )
|
67 | 67 | }
|
68 | 68 |
|
69 | 69 | //------ Custom Layout Parts --------
|
70 | 70 | export const RoutedNavbars = () => (
|
71 |
| - <Switch> |
| 71 | + <Routes> |
72 | 72 | <Route
|
73 |
| - component={() => ( |
| 73 | + path="/*" |
| 74 | + element={ |
74 | 75 | <GluuNavBar themeStyle="color" themeColor="primary" navStyle="accent" />
|
75 |
| - )} |
| 76 | + } |
76 | 77 | />
|
77 |
| - </Switch> |
| 78 | + </Routes> |
78 | 79 | )
|
79 | 80 |
|
80 | 81 | export const RoutedSidebars = () => (
|
81 |
| - <Switch> |
82 |
| - <Route component={DefaultSidebar} /> |
83 |
| - </Switch> |
| 82 | + <Routes> |
| 83 | + <Route path="/*" element={<DefaultSidebar />} /> |
| 84 | + </Routes> |
84 | 85 | )
|
0 commit comments