6

This is what my react-router code looks like

render((
<Router history={browserHistory}>
    <Route path={CORP} component={App}>
      <IndexRoute component={Home} />
      <Route path={"outreach"} component={OutReach}/>
      <Route path={"careers/m"} component={Career}/>
      <Route path={"members"} component={Members}/>
      <Redirect from="*" to={"/home"} />
    </Route>
  </Router>
), document.getElementById('app'))

But when I go to my page, I get this error in my console

Uncaught ReferenceError: Redirect is not defined

How do I tell react-router to redirect the user to the /home only when the user's destination does not match any of the route paths mentioned above?

John
  • 32,403
  • 80
  • 251
  • 422

1 Answers1

18

You just need to add

import { Redirect } from 'react-router';

In the top of your file

Vlad Dekhanov
  • 1,066
  • 1
  • 13
  • 27