我在路由器上设置了browserHistory(react-router 2.0):
import { browserHistory } from 'react-router'
function requireAuth(nextState, replace) {
if (!services.auth.loggedIn()) {
replace({
pathname: '/login',
state: { nextPathname: nextState.location.pathname }
})
}
}
export default (store) => (
);
然后我尝试在react-router中使用browserHistory以编程方式从视图路由到新页面,ala:
import { browserHistory } from 'react-router'
...
browserHistory.push('/map');
这会将URL更改为/ map,但不会呈现该路由中的组件 . 我究竟做错了什么?