react路由報錯
react路由報錯:A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>

解決方法:
在index.js文件中,用<Routes>包圍 <Route>
修改:
<Route path='/about' component={<About/>} />
為,
<Route path='/about' element={<About/>}?
就這樣式的,
import {Route, Routes, HashRouter} from 'react-router-dom'
<Routes>
? ? ? ? ? <Route path='/about' element={<About/>} />
</Routes>
標簽: