728x90
반응형
[Context] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>
Router 컴포넌트에서 났던 오류!
상황
contextAPI를 사용하기 위해
<Context> 컴포넌트를 만들어 코드를 작성하고
전역으로 쓰기 위해 라우터에서 감쌌다 👇

<Routes>안으로 감싸버렸더니 Routes 자식으론 나 <> 밖에 못 받는다는 오류가 나왔다
react-router-dom v6 부터 <switch> 대신 <Routes> 를 쓰는데
오류가 뱉은 그대로
<Routes> 안에는
<Route path ="" element={<컴포넌트/>} />
형태만 자식으로 올 수 있다
해결
<Routes>를 안에 써주었다

728x90
반응형
'TIL' 카테고리의 다른 글
react 오류 : Element type is invalid, expected a string (for built-in components) or a class/function but got : (0) | 2023.02.06 |
---|---|
react) codebox에서 받은 파일 npm i 안 될 때 (0) | 2023.01.21 |
React 깔끔하게 컴포넌트 import 하기 (0) | 2023.01.19 |
observer API 무한스크롤 (0) | 2023.01.08 |
프로그래머스 js 마법의 엘리베이터 (0) | 2022.12.31 |
댓글