"React Router 4 Basics " was retired on October 1, 2023. You are now viewing the recommended replacement.

Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Router 4 Basics Navigating, Nesting and Redirecting Routes Using the Match Object

Robert Cooper
Robert Cooper
22,704 Points

Why not define the Header Routes in Header.js instead of App.js?

I'm curious as to why the Routes for the Header are defined in App.js instead of inside of Header.js. Wouldn't it be easier to keep all the Routes in the same file as the the NavLinks, just like we did for Courses.js.

Here are the routes i'm reffering to in App.js:

<div className="container">
  <Header/>
  <Route exact path="/" component={Home}/>
  <Route path="/about" render={ () => <About title="About" /> }/>
  <Route path="/teachers" component={Teachers}/>
  <Route path="/courses" component={Courses}/>
</div>