0

I'm trying to run a project based on session timeout in reactjs.. But unfortunately an error occurs.. This is the error,
'react-router' does not contain an export named 'browserHistory'.

Aswin
  • 137
  • 2
  • 9
Sarah
  • 25
  • 1
  • 10
  • Are you looking for `BrowserRouter`? – Agney May 02 '18 at 04:52
  • Possible duplicate of [React router not showing browser history](https://stackoverflow.com/questions/44063229/react-router-not-showing-browser-history) – Aswin May 02 '18 at 04:53

2 Answers2

0

I think you're using React Router 4. It moves around some of those modules. You'll either need to migrate your code to use v4, or downgrade React Router in your package.json.

React router provides a migration guide here:

https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/migrating.md

themollusk
  • 440
  • 4
  • 10
0

I think you are using react-router latest version. In new version history managed by internally. you can just use like and history is avaliable in your component props like props.history

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


let RootApp = () => {   
   return (
      <div>
        <HashRouter>
            <Switch>                  
              <PrivateRoute path='/admin' component={AdminRoute} /> 
              <Route path='/login' component={LoginComponet}></Route>
              <Route path='/**' component={LoginComponet}></Route>             
            </Switch>
        </HashRouter>
      </div>
    );
}
Birbal Singh
  • 1,062
  • 7
  • 16