reactjs - Problems using a custom history in react-router 2.0.0 -


specifically want use "basename" option can run application in sub directory.

i have following code set-up history.

var createhistory = require('history').createhistory; var userouterhistory = require('react-router').userouterhistory; var browserhistory = userouterhistory(createhistory)({     basename: "/subfolder" }); 

i have following route config

<router history={browserhistory} classname="react-container">     <route path="/" component={template}>         <indexroute component={diary} />         <route path="diary(/:zoom)" component={diary} />         <route path="login" component={login} />     </route> </router> 

i can route without problems in components using:

this.context.router.push('login'); 

but when try , push new route history in flux store doesn't work. change url in address bar correct value, component not change. can refresh page , loads expected.

for example can use:

//require browser history in store var browserhistory = require('react-router').browserhistory; .... //after login browserhistory.push('/'); 

i expect "diary" component load, instead changes url /subfolder , component stays login page.

the routing works correctly if use

require('react-router').browserhistory 

instead of custom code, can't run application in sub directory need.

thanks in advance , tips can give me. chris

in flux store, need make sure use same history object set router.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -