happyZZR1400 happyZZR1400 - 1 year ago 111
Javascript Question

cannot configure react-router to run on plunkr

i'm starting to teach myself react now and i currently starting to play with react-router.
For some reason ,my project cannot run with Router tag on this plunkr

<Router history={browserHistory}>
<Route path="/" component={SearchPage}></Route>

The error is "Router not defined"

I know - very basic question, but may be thats reason it will be very easy to answer


Answer Source
  1. you can use it something like that (es6):

    const {Router, Link, hashHistory, Route, withRouter} = ReactRouter;


  2. or if you prefer es5

    var Router = ReactRouter.Router;
    var Route = ReactRouter.Route;
    var hashHistory = ReactRouter.hashHistory;


  3. also you can use es6 modules with webpackbin

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download