티스토리 뷰

리액트 라우터를 사용해서 컴포넌트를 불러오는데 이렇게 쓰니까 오류가 남

<Route path="/rock-scissors-paper" component={RSP}/>
--------------------------------------------------------------
Matched leaf route at location "/rock-scissors-paper" does not have an element.

Matched leaf route at location "/rock-scissors-paper" does not have an element.

해당 위치에 일치하는 엘리먼트가 없다


<Route path="/rock-scissors-paper" element={<RSP />} />

component를 element로 고쳐서 입력하면 잘 작동함


react-router-dom버전이 6인지 5인지 확인해볼것!

6이면 component가 사용이 안되서 위 방법대로 element를 써야하는 것 같음

5이면 component 사용 가능!

npm i react-router-dom@5.3.0 으로 설치하면 됨!

 

참고

https://stackoverflow.com/questions/69854011/matched-leaf-route-at-location-does-not-have-an-element

 

Matched leaf route at location "/" does not have an element

Matched leaf route at location "/" does not have an element. This means it will render an with a null value by default resulting in an "empty" page //App.js File import {

stackoverflow.com

 

댓글 확인

https://www.youtube.com/watch?v=veXqpfcis0A&list=PLcqDmjxt30RtqbStQqk-eYMK8N-1SYIFn&index=64 

 

728x90
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함