Skip to content

Commit e017fda

Browse files
authored
Merge pull request #364 from lbz-life/update-react-router-dom-6.2.1
Update react router dom 6.2.1
2 parents 96122c6 + da16cc4 commit e017fda

File tree

7 files changed

+93
-155
lines changed

7 files changed

+93
-155
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"react-app-polyfill": "^2.0.0",
4646
"react-dom": "^17.0.2",
4747
"react-redux": "^7.2.6",
48-
"react-router-dom": "^5.3.0",
48+
"react-router-dom": "^6.2.1",
4949
"redux": "4.1.2",
5050
"simplebar-react": "^2.3.6"
5151
},

src/App.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { Component } from 'react'
2-
import { HashRouter, Route, Switch } from 'react-router-dom'
1+
import React, { Component, Suspense } from 'react'
2+
import { HashRouter, Route, Routes } from 'react-router-dom'
33
import './scss/style.scss'
44

55
const loading = (
@@ -21,20 +21,15 @@ class App extends Component {
2121
render() {
2222
return (
2323
<HashRouter>
24-
<React.Suspense fallback={loading}>
25-
<Switch>
26-
<Route exact path="/login" name="Login Page" render={(props) => <Login {...props} />} />
27-
<Route
28-
exact
29-
path="/register"
30-
name="Register Page"
31-
render={(props) => <Register {...props} />}
32-
/>
33-
<Route exact path="/404" name="Page 404" render={(props) => <Page404 {...props} />} />
34-
<Route exact path="/500" name="Page 500" render={(props) => <Page500 {...props} />} />
35-
<Route path="/" name="Home" render={(props) => <DefaultLayout {...props} />} />
36-
</Switch>
37-
</React.Suspense>
24+
<Suspense fallback={loading}>
25+
<Routes>
26+
<Route exact path="/login" name="Login Page" element={<Login />} />
27+
<Route exact path="/register" name="Register Page" element={<Register />} />
28+
<Route exact path="/404" name="Page 404" element={<Page404 />} />
29+
<Route exact path="/500" name="Page 500" element={<Page500 />} />
30+
<Route path="*" name="Home" element={<DefaultLayout />} />
31+
</Routes>
32+
</Suspense>
3833
</HashRouter>
3934
)
4035
}

src/components/AppContent.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Suspense } from 'react'
2-
import { Redirect, Route, Switch } from 'react-router-dom'
2+
import { Navigate, Route, Routes } from 'react-router-dom'
33
import { CContainer, CSpinner } from '@coreui/react'
44

55
// routes config
@@ -9,26 +9,22 @@ const AppContent = () => {
99
return (
1010
<CContainer lg>
1111
<Suspense fallback={<CSpinner color="primary" />}>
12-
<Switch>
12+
<Routes>
1313
{routes.map((route, idx) => {
1414
return (
15-
route.component && (
15+
route.element && (
1616
<Route
1717
key={idx}
1818
path={route.path}
1919
exact={route.exact}
2020
name={route.name}
21-
render={(props) => (
22-
<>
23-
<route.component {...props} />
24-
</>
25-
)}
21+
element={<route.element />}
2622
/>
2723
)
2824
)
2925
})}
30-
<Redirect from="/" to="/dashboard" />
31-
</Switch>
26+
<Route path="/" element={<Navigate to="dashboard" replace />} />
27+
</Routes>
3228
</Suspense>
3329
</CContainer>
3430
)

src/components/AppHeader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const AppHeader = () => {
3636
</CHeaderBrand>
3737
<CHeaderNav className="d-none d-md-flex me-auto">
3838
<CNavItem>
39-
<CNavLink to="/dashboard" component={NavLink} activeClassName="active">
39+
<CNavLink to="/dashboard" component={NavLink}>
4040
Dashboard
4141
</CNavLink>
4242
</CNavItem>

src/components/AppSidebarNav.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const AppSidebarNav = ({ items }) => {
2828
{...(rest.to &&
2929
!rest.items && {
3030
component: NavLink,
31-
activeClassName: 'active',
3231
})}
3332
key={index}
3433
{...rest}

src/routes.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -52,49 +52,49 @@ const Widgets = React.lazy(() => import('./views/widgets/Widgets'))
5252

5353
const routes = [
5454
{ path: '/', exact: true, name: 'Home' },
55-
{ path: '/dashboard', name: 'Dashboard', component: Dashboard },
56-
{ path: '/theme', name: 'Theme', component: Colors, exact: true },
57-
{ path: '/theme/colors', name: 'Colors', component: Colors },
58-
{ path: '/theme/typography', name: 'Typography', component: Typography },
59-
{ path: '/base', name: 'Base', component: Cards, exact: true },
60-
{ path: '/base/accordion', name: 'Accordion', component: Accordion },
61-
{ path: '/base/breadcrumbs', name: 'Breadcrumbs', component: Breadcrumbs },
62-
{ path: '/base/cards', name: 'Cards', component: Cards },
63-
{ path: '/base/carousels', name: 'Carousel', component: Carousels },
64-
{ path: '/base/collapses', name: 'Collapse', component: Collapses },
65-
{ path: '/base/list-groups', name: 'List Groups', component: ListGroups },
66-
{ path: '/base/navs', name: 'Navs', component: Navs },
67-
{ path: '/base/paginations', name: 'Paginations', component: Paginations },
68-
{ path: '/base/placeholders', name: 'Placeholders', component: Placeholders },
69-
{ path: '/base/popovers', name: 'Popovers', component: Popovers },
70-
{ path: '/base/progress', name: 'Progress', component: Progress },
71-
{ path: '/base/spinners', name: 'Spinners', component: Spinners },
72-
{ path: '/base/tables', name: 'Tables', component: Tables },
73-
{ path: '/base/tooltips', name: 'Tooltips', component: Tooltips },
74-
{ path: '/buttons', name: 'Buttons', component: Buttons, exact: true },
75-
{ path: '/buttons/buttons', name: 'Buttons', component: Buttons },
76-
{ path: '/buttons/dropdowns', name: 'Dropdowns', component: Dropdowns },
77-
{ path: '/buttons/button-groups', name: 'Button Groups', component: ButtonGroups },
78-
{ path: '/charts', name: 'Charts', component: Charts },
79-
{ path: '/forms', name: 'Forms', component: FormControl, exact: true },
80-
{ path: '/forms/form-control', name: 'Form Control', component: FormControl },
81-
{ path: '/forms/select', name: 'Select', component: Select },
82-
{ path: '/forms/checks-radios', name: 'Checks & Radios', component: ChecksRadios },
83-
{ path: '/forms/range', name: 'Range', component: Range },
84-
{ path: '/forms/input-group', name: 'Input Group', component: InputGroup },
85-
{ path: '/forms/floating-labels', name: 'Floating Labels', component: FloatingLabels },
86-
{ path: '/forms/layout', name: 'Layout', component: Layout },
87-
{ path: '/forms/validation', name: 'Validation', component: Validation },
88-
{ path: '/icons', exact: true, name: 'Icons', component: CoreUIIcons },
89-
{ path: '/icons/coreui-icons', name: 'CoreUI Icons', component: CoreUIIcons },
90-
{ path: '/icons/flags', name: 'Flags', component: Flags },
91-
{ path: '/icons/brands', name: 'Brands', component: Brands },
92-
{ path: '/notifications', name: 'Notifications', component: Alerts, exact: true },
93-
{ path: '/notifications/alerts', name: 'Alerts', component: Alerts },
94-
{ path: '/notifications/badges', name: 'Badges', component: Badges },
95-
{ path: '/notifications/modals', name: 'Modals', component: Modals },
96-
{ path: '/notifications/toasts', name: 'Toasts', component: Toasts },
97-
{ path: '/widgets', name: 'Widgets', component: Widgets },
55+
{ path: '/dashboard', name: 'Dashboard', element: Dashboard },
56+
{ path: '/theme', name: 'Theme', element: Colors, exact: true },
57+
{ path: '/theme/colors', name: 'Colors', element: Colors },
58+
{ path: '/theme/typography', name: 'Typography', element: Typography },
59+
{ path: '/base', name: 'Base', element: Cards, exact: true },
60+
{ path: '/base/accordion', name: 'Accordion', element: Accordion },
61+
{ path: '/base/breadcrumbs', name: 'Breadcrumbs', element: Breadcrumbs },
62+
{ path: '/base/cards', name: 'Cards', element: Cards },
63+
{ path: '/base/carousels', name: 'Carousel', element: Carousels },
64+
{ path: '/base/collapses', name: 'Collapse', element: Collapses },
65+
{ path: '/base/list-groups', name: 'List Groups', element: ListGroups },
66+
{ path: '/base/navs', name: 'Navs', element: Navs },
67+
{ path: '/base/paginations', name: 'Paginations', element: Paginations },
68+
{ path: '/base/placeholders', name: 'Placeholders', element: Placeholders },
69+
{ path: '/base/popovers', name: 'Popovers', element: Popovers },
70+
{ path: '/base/progress', name: 'Progress', element: Progress },
71+
{ path: '/base/spinners', name: 'Spinners', element: Spinners },
72+
{ path: '/base/tables', name: 'Tables', element: Tables },
73+
{ path: '/base/tooltips', name: 'Tooltips', element: Tooltips },
74+
{ path: '/buttons', name: 'Buttons', element: Buttons, exact: true },
75+
{ path: '/buttons/buttons', name: 'Buttons', element: Buttons },
76+
{ path: '/buttons/dropdowns', name: 'Dropdowns', element: Dropdowns },
77+
{ path: '/buttons/button-groups', name: 'Button Groups', element: ButtonGroups },
78+
{ path: '/charts', name: 'Charts', element: Charts },
79+
{ path: '/forms', name: 'Forms', element: FormControl, exact: true },
80+
{ path: '/forms/form-control', name: 'Form Control', element: FormControl },
81+
{ path: '/forms/select', name: 'Select', element: Select },
82+
{ path: '/forms/checks-radios', name: 'Checks & Radios', element: ChecksRadios },
83+
{ path: '/forms/range', name: 'Range', element: Range },
84+
{ path: '/forms/input-group', name: 'Input Group', element: InputGroup },
85+
{ path: '/forms/floating-labels', name: 'Floating Labels', element: FloatingLabels },
86+
{ path: '/forms/layout', name: 'Layout', element: Layout },
87+
{ path: '/forms/validation', name: 'Validation', element: Validation },
88+
{ path: '/icons', exact: true, name: 'Icons', element: CoreUIIcons },
89+
{ path: '/icons/coreui-icons', name: 'CoreUI Icons', element: CoreUIIcons },
90+
{ path: '/icons/flags', name: 'Flags', element: Flags },
91+
{ path: '/icons/brands', name: 'Brands', element: Brands },
92+
{ path: '/notifications', name: 'Notifications', element: Alerts, exact: true },
93+
{ path: '/notifications/alerts', name: 'Alerts', element: Alerts },
94+
{ path: '/notifications/badges', name: 'Badges', element: Badges },
95+
{ path: '/notifications/modals', name: 'Modals', element: Modals },
96+
{ path: '/notifications/toasts', name: 'Toasts', element: Toasts },
97+
{ path: '/widgets', name: 'Widgets', element: Widgets },
9898
]
9999

100100
export default routes

0 commit comments

Comments
 (0)