I'm trying to render out new components without showing the original home component. I separated my components and now when I try to render them out it doesn't display.
class App extends Component {
render() {
return (
<div>
<Route exact={true} path="/" component={Home} />
</div>
);
}
}
Here is my home component that is supposed to render the About component and Pages component, but currently when I click it it doesn't display anything.
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>
)
My About component:
const About = () => (
<div>
<h2>About page</h2>
</div>
)
My pages component:
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>
)