"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.

반응형