Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Router Redux go action is shown in the LogMonitor but doesn't change the path on browser

Tags:

reactjs

redux

I'm using react-redux-starter-kit on one of my views I just want to redirects users is somethig is not set My components is fairly simple

// 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)

I can see the LOCATION_CHANGE action triggered but doesn't show the destination view

enter image description here

like image 507
rkmax Avatar asked Mar 02 '16 18:03

rkmax


1 Answers

I've found I missed the setup of syncHistoryWithStore after that it's works like a charm using the react-router API

import { browserHistory } from 'react-router'

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

I dont need dispatch any more for change the location

like image 165
rkmax Avatar answered Oct 14 '22 03:10

rkmax