"useRoutes() may be used only in the context of a <Router> component."
2023. 3. 24. 09:36ㆍ개발/토막난 상식
반응형
"useRoutes는 <Router>로 감싸야합니다.
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
<Router> <Routes> <Route path="/" element={<Main />} /> <Route path="/Login" element={<Login />} /> </Routes> </Router>
로 해결!
스위치 >> v6 에서는
Routes
로 변경
BrowserRouter 사용 이유
BrowserRouter: Uses the HTML5 history API (pushState, replaceState and the popstate event) to keep your UI in sync with the URL.
반응형
'개발 > 토막난 상식' 카테고리의 다른 글
폴더 구성 - 모노레포 (0) | 2023.03.24 |
---|---|
html 구성요소 (0) | 2023.03.24 |
export 'Switch' (imported as 'Switch') was not found in 'react-router-dom' (0) | 2023.03.23 |
Cannot read properties of undefined (0) | 2023.03.23 |
[object Object] 오류해결 (0) | 2023.03.22 |