-
[에러] 빈 화면에 console창에 Matched leaf route at location "/" does not have an element. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.React 2022. 9. 14. 21:48
문제점 :
Matched leaf route at location "/" does not have an element. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.
문제 코드 :
<HashRouter><Routes><Route path="/" component={Home}>{/* <h1>Home</h1> */}</Route><Route path="/about" component={About}>{/* <h1>About</h1> */}</Route></Routes></HashRouter>해결방법
1. component를 element로 수정한다.
2. {컴포넌트명}을 {<컴포넌트명/>}으로 수정한다.
코드는 아래와 같다.
<HashRouter><Routes><Route path="/" element={<Home/>}></Route><Route path="/about" element={<About/>}></Route></Routes></HashRouter>'React' 카테고리의 다른 글
[영화 소개 사이트] Git에 올리고 배포하기 (0) 2022.09.15 [에러] props의 값이 들어오지 않는다. (0) 2022.09.15 [에러] 빈 화면이 뜨고 console창에 A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes> (0) 2022.09.14 영화 API 사용해보기 (0) 2022.09.13 prop-types -정의,사용 예제 (0) 2022.09.13