Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript React Router Basics Going Further with Routes Displaying 404 Error Routes

Giuseppe Barbera
Giuseppe Barbera
1,933 Points

index.html output blank page

how can se the output in index.html ? in localhost all works fine, but index.html i see only the menu, no router etc etc

3 Answers

Jonathan Dewitt
Jonathan Dewitt
8,101 Points

To use this with current versions of react-router (v4) you need to use a switch element. This is how I got mine to work:

// Routes
const routes = (
    <Router history={History}>
                <Route exact path="/" component={Home} />
                <Route path="/about" component={About} />
                <Route path="/courses" component={Courses} />
                <Route path="/teachers" component={Teachers} />
                <Route component={NotFound} />

To see errors, press Cmmd+Shift+i on a Mac and Ctrl-Shift-i on Windows. I recommend doing this on Google Chrome or Firefox since I think you have to install things when using other browsers.

Giuseppe Barbera
Giuseppe Barbera
1,933 Points

No error in console, in i launch npm start and localhost all work fine.. but if open the html Only page blank..the bundle.js its compiled...

Can you show your HTML?