2016-03-02 23 views
6

我使用react-redux-starter-kit对我的看法我只是想将用户重定向是somethig没有设置我的一个组件不改变浏览器的路径是相当简单的阵营路由器Redux的去行动显示在LogMonitor但

// MyComponentWithRedirect.js 
import React, {Component, PropTypes} from 'react' 
import {connect} from 'react-redux' 
import {go} from 'react-router-redux' 

class MyComponentWithRedirect extends Component { 
    static propTypes = { 
    userInfo: PropTypes.object.isRequired, 
    dispatch: PropTypes.func.isRequired 
    } 

    componentDidMount() {   
    if (this.props.userInfo.firstTime) { 
     this.props.dispatch(go('/welcome')) 
    } 
    } 
} 

const mapStateToProps = (state) => ({userInfo: state.userInfo}) 

export default connect(mapStateToProps)(MyComponentWithRedirect) 

我可以看到触发LOCATION_CHANGE动作,但不显示目的地视图

enter image description here

回答

3

我发现我错过了syncHistoryWithStore的设置使用,它的作品就像一个魅力后反应路由器API

import { browserHistory } from 'react-router' 

... 
browserHistory.push('/welcome') 

我不需要任何派遣更多的改变位置