원본 홈 구성 요소를 표시하지 않고 새 구성 요소를 렌더링하려고합니다. 구성 요소를 분리했는데 렌더링하려고 할 때 표시되지 않습니다.대응 라우터가 구성 요소를 렌더링하지 않습니까?
class App extends Component {
render() {
return (
<div>
<Route exact={true} path="/" component={Home} />
</div>
);
}
}
다음은 About
구성 요소 및 Pages
구성 요소를 렌더링하도록되어 내 고향 구성 요소이지만, 현재 내가 그것을 클릭 할 때 아무것도 표시되지 않습니다.
const Home =() => (
<div>
<h2>Home page</h2>
<div>
<ul>
<li><Link to="/about">About</Link></li>
<li><Link to="/pages">Page with Subpages</Link></li>
</ul>
<Route path="/about" component={About} />
<Route path="/pages" component={Pages} />
</div>
</div>
)
내 약 성분 :
const About =() => (
<div>
<h2>About page</h2>
</div>
)
내 페이지 구성 요소 : 귀하의 경우에는 당신과 페이지 구성 요소에서 정보 배치 때문에
const Pages = ({ match }) => (
<div>
<h2>Page with Subpages</h2>
<ul>
<li><Link to={`${match.url}/subpage1`}>Subpage 1</Link></li>
<li><Link to={`${match.url}/subpage2`}>Subpage 2</Link></li>
<li><Link to={`${match.url}/subpage3`}>Subpage 3</Link></li>
</ul>
<Route path={`${match.url}/subpage1`} component={Subpage1}/>
<Route path={`${match.url}/subpage2`} component={Subpage2}/>
<Route path={`${match.url}/subpage3`} component={Subpage3}/>
</div>
)