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 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: "/"