score:0

this is the correct link to react-router-redux v4 example. you have to use connectedrouter from react-router-redux and pass history. i configured my project yesterday based on this example and it works fine.

score:0

in react router v4, your configuration should be something like below.

 import { browserrouter, route, switch } from 'react-router-dom';

 <provider store={createstorewithmiddleware(reducers)}>
    <browserrouter>
      <div>
        <switch>
            <route path="/api/:id" component={componentone} />
            <route path="/" component={home} />
        </switch>
      </div>
    </browserrouter>
  </provider>

the api has been changed since the previous version. also note that the order matters. keep the most specific paths at the top.

score:0

in my project, i get rid of this type of error in two steps:

  1. step in to import import createbrowserhistory from 'history/createbrowserhistory'; and declaring const customhistory = createbrowserhistory(); like this:

    import  { browserrouter as staticrouter, router, switch, route, link } from 'react-router-dom';
    import  createbrowserhistory from 'history/createbrowserhistory';
    const   customhistory = createbrowserhistory();
    
  2. it looks like that it is necessary to add history attribute to the router:

    <router history={customhistory}>
    <div>
        <link to={'/.../' + linkname1}>
            {itemname1}
        </link>
        <link to={'/.../' + linkname2}>
            {itemname2}
        </link>
    </div>
    


Related Query

More Query from same tag