You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importReactfrom'react'import{render}from'react-dom'import{match,Router,browserHistoryashistory}from'react-router'classAppextendsReact.Component{render(){console.log(this.context.router.isActive('/about'));// false on first renderreturn(<div><h1>App</h1>{this.props.children}</div>)}}App.contextTypes={router: React.PropTypes.object};constroutes={path: '/',component: App,childRoutes: [{path: '/about',component: App,onEnter: (nextState,replace,callback)=>{setTimeout(()=>{callback()},1000)}}]};const{ pathname, search, hash }=window.location;constlocation=`${pathname}${search}${hash}`;match({
routes,
location,
history
},(error,redirectLocation,renderProps)=>{console.log(renderProps.router.isActive('/about'));// return truerender(<Router{...renderProps}history={history}// if pass renderProps.history, well show `router.history` warning./>,document.getElementById('app'))});
However, �
If an async method in onEnter,
The router in Router will re-initial, and the router.isActive will return false, until onEnter callback, and re-render the Router. ( see the console.log in code, above)
This may break lazy match in client.
And in server render, The Link active state, will be different between client and server.
The text was updated successfully, but these errors were encountered:
taion
changed the title
If an async method in onEnter,context.router.isActive is not same as renderProps.router.isActivewhen first render.
Properly initialize <Router> state after match
Jan 27, 2016
Since could through the renderProps to Router
https://github.com/rackt/react-router/blob/v2.0.0-rc5/modules/Router.js#L46
we could use match on client like this ? (should this correct ? )
However, �
If an async method in onEnter,
The
router
in Router will re-initial, and therouter.isActive
will return false, until onEnter callback, and re-render the Router. ( see theconsole.log
in code, above)This may break lazy match in client.
And in server render, The
Link
active state, will be different between client and server.The text was updated successfully, but these errors were encountered: