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

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

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

      <Switch>
        <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} />
      </Switch>
    </div>
 </HashRouter>

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).