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 Basics Navigating and Nesting Routes Index Routes and Redirects

parent URL repeating for child Links /courses/courses/courses/courses/courses/css

Everything works.. However each time the child URL is clicked the parent URL repeats itself.


        <Route path="courses" component={Courses}>
          <IndexRedirect to="html"/>
          <Route path="html" component={HTML} />
          <Route path="css" component={CSS} />
          <Route path="javascript" component={JavaScript} />
         <ul className="course-nav">
            <li><Link to="courses/html" activeClassName="active">HTML</Link></li>
            <li><Link to="courses/css" activeClassName="active">CSS</Link></li>
            <li><Link to="courses/javascript" activeClassName="active">JavaScript</Link></li>

Solved my own problem. I swapped the initial browserHistory import for the code below.

import React from 'react';
import {Router, Route,  IndexRedirect} from 'react-router';

import { createHistory, useBasename } from "history";
const browserHistory = useBasename(createHistory)({
    basename: "/"