React 오류 기록
Uncaught TypeError: Cannot read properties of undefined (reading 'pathname')
🤯 문제
path 이름이 정의가 되지 않았다고 하는데, 그걸 어디서 정의하지?
직독직해 하는 기분....
<Router>
<Routes>
<Route path="/" element={<HomeContainer/>} />
<Route path="/local" element={<LocalContainer />} />
<Route path="/national" element={<NationalContainer />} />
<Route path="/beginner" element={<BeginnerContainer />} />
<Route path="/height" element={<HeightContainer />} />
</Routes>
</Router>
🥳 문제 해결
import { BrowserRouter, Route, Routes } from "react-router-dom";
<BrowserRouter>
<Routes>
<Route path="/" element={<HomeContainer />} />
<Route path="/local" element={<LocalContainer />} />
<Route path="/national" element={<NationalContainer />} />
<Route path="/beginner" element={<BeginnerContainer />} />
<Route path="/height" element={<HeightContainer />} />
</Routes>
</BrowserRouter>
ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ
BrowserRouter안에 넣으니까 pathname도 찾나보다..

드디어 화면에 뜬다!!!🤸🏻♀️🤸🏻♀️
'유쾌하지 못한 오류 기록' 카테고리의 다른 글
Git 오류 기록 git switch가 되지 않을 때 (0) | 2023.01.06 |
---|---|
React 오류 기록 Uncaught Error: useRoutes() may be used only in the context of a <Router> component. (0) | 2023.01.03 |
Git 오류 기록 cannot lock ref 'refs/remotes/origin' (0) | 2023.01.03 |
React 오류 기록 npm start와 yatn start가 안될 때 (0) | 2023.01.02 |
React 오류 기록 Module not found: Error: Can't resolve (0) | 2022.12.30 |