Skip to content

Commit b5cdc45

Browse files
committed
refactor: renamed Switch to Routes, renamed render to element, and replaced Redirect with Navigate
1 parent c2dd4e7 commit b5cdc45

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/components/AppContent.js

Lines changed: 5 additions & 9 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,7 +9,7 @@ const AppContent = () => {
99
return (
1010
<CContainer lg>
1111
<Suspense fallback={<CSpinner color="primary" />}>
12-
<Switch>
12+
<Routes>
1313
{routes.map((route, idx) => {
1414
return (
1515
route.component && (
@@ -18,17 +18,13 @@ const AppContent = () => {
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.component />}
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
)

0 commit comments

Comments
 (0)