Electron-react-boilerplate: Browser history not working in electron app

Created on 16 Aug 2017  路  3Comments  路  Source: electron-react-boilerplate/electron-react-boilerplate

My electron app works fine with HashHistory, but when I switch to browserHistory,not working fine.
I noticed that the two have different initial pathname.

const history = createHashHistory();
console.log(history.location.pathname);     
//  "/"
const history = createBrowserHistory();
console.log(history.location.pathname);     
//  "/C:/Users/asdf/Documents/GitHub/electron-react-boilerplate/app/app.html"
//  This path matches the route "/C:/"
//  and when I use "history.goBack()" and "history.goForward()" also found some errors

Most helpful comment

then i use the following code, the problem is solved.

const history = createBrowserHistory({
  basename: window.location.pathname
});

All 3 comments

then i use the following code, the problem is solved.

const history = createBrowserHistory({
  basename: window.location.pathname
});

Just ran into this same issue. Thanks for providing the solution!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kennetpostigo picture kennetpostigo  路  3Comments

juangl picture juangl  路  4Comments

andy547320 picture andy547320  路  3Comments

anubra266 picture anubra266  路  3Comments

helpceo picture helpceo  路  3Comments