React Redux state change

后端 未结 2 1019
生来不讨喜
生来不讨喜 2020-12-06 22:52

this.props.authState stays the same although I\'m dispatching an action in my componentDidMount function:

componentDidMount() {
            


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 23:55

    If you’re mutating the state then component will not be re rendered. You need to return {...state, authState} from your reducer. And you verify your updated state in

    componentWillReceiveProps(nextProps)
      {
       }
    

    I hope this would solve the issue.

提交回复
热议问题