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.


Line 18: 'HashRouter' is not defined react/jsx-no-undef

I changed <BroswerRouter> to <HashRouter> but fail , show that Line 18: 'HashRouter' is not defined react/jsx-no-undef . I followed at 4:12 https://teamtreehouse.com/library/deploy-to-github-pages

    <div className="container">
      <Header />

        <Route exact path="/" component={Home} />
        <Route path="/about" render={ () => <About title='About' /> } />
        <Route exact path="/teachers" component={Teachers} />
        <Route path="/teachers/:topic/:name" component={Featured} />
        <Route path="/courses" component={Courses} />
        <Route component={NotFound} />

1 Answer

David Gilfillan
David Gilfillan
12,928 Points

Hi, to use the component "HashRouter", you need to import "HashRouter" instead of "BrowserRouter"

import React from 'react'; import { HashRouter, Route, Switch } from 'react-router-dom';

David Gilfillan
David Gilfillan
12,928 Points

Also you need to make sure not to use a basename if you publishing to GitHub pages

Setting a basename on a HashRouter will append that pseudo-path-segment to the part after the hash. You shouldn't need to use a basename with HashRouter (because everything is already relative to the base path).