11import * as React from 'react'
2- import { Switch , Link , Route , Redirect , useLocation } from 'react-router-dom'
2+ import { Routes , Link , Route , Navigate , useLocation } from 'react-router-dom'
33import cx from 'classnames'
44import { ifDev , ifProd , ifPrerender } from 'crd-client-utils'
55import Menu from '../component/Menu'
@@ -104,7 +104,7 @@ function BasicLayout({
104104 </ span >
105105 ) : (
106106 < Link
107- to = { ifProd ? `/${ repo } ${ path } ` : path }
107+ to = { ifProd ? `/${ repo } ${ path } ` : ` ${ path } ` }
108108 replace = { pathname . indexOf ( path ) > - 1 }
109109 >
110110 { item && item . mdconf && item . mdconf . title
@@ -245,12 +245,11 @@ function BasicLayout({
245245 [ `${ styles [ "content-fullpage" ] } ` ] : inlineCollapsed || isMobile ,
246246 } ) }
247247 >
248- < Switch >
248+ < Routes >
249249 { /* see https://reacttraining.com/react-router/web/api/Redirect/exact-bool */ }
250250 < Route
251- exact
252251 path = { ifAddPrefix ? `/${ repo } ` : `/` }
253- render = { ( ) => < Redirect to = { ifAddPrefix ? `/${ repo } /${ defaultPath } ` : `/${ defaultPath } ` } /> }
252+ element = { < Navigate to = { ifAddPrefix ? `/${ repo } /${ defaultPath } ` : `/${ defaultPath } ` } replace /> }
254253 />
255254 { routeData . map ( ( item ) => {
256255 const { path, mdconf, component } = item
@@ -260,35 +259,30 @@ function BasicLayout({
260259 return (
261260 < Route
262261 key = { enhancePath }
263- exact
264262 path = { ifAddPrefix ? `/${ repo } ${ enhancePath } ` : enhancePath }
265- >
266- < Comp { ...item } />
267- </ Route >
263+ element = { < Comp { ...item } /> }
264+ />
268265 )
269266 } ) }
270267 {
271268 tags
272269 ? < >
273270 < Route
274271 key = '/tags'
275- exact
276272 path = { ifAddPrefix ? `/${ repo } /tags` : '/tags' }
277- >
278- < Tags />
279- </ Route >
273+ element = { < Tags /> }
274+ />
280275 < Route
281276 key = '/tags/:name'
282277 path = { ifAddPrefix ? `/${ repo } /tags/:name` : '/tags/:name' }
283- >
284- < Tags />
285- </ Route >
278+ element = { < Tags /> }
279+ />
286280 </ >
287281 : null
288282 }
289283 { /* Todo: follow up how to use Redirect to back up the rest of route. */ }
290284 { /* <Redirect path='/' to={ifAddPrefix ? `/${repo}/404` : `/404`} /> */ }
291- </ Switch >
285+ </ Routes >
292286 { renderPageFooter ( ) }
293287 </ div >
294288 )
0 commit comments