mapStateToProps must return an object. Instead received Map {}?

后端 未结 1 1502
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-06 02:42

Hello i use Immuteble Map for state and when i try maspStateToProps i have this error.

Uncaught Invariant Violation: mapStateToProps must re

1条回答
  •  一生所求
    2021-02-06 03:18

    This github issue covers this exact problem: https://github.com/reactjs/react-redux/issues/60.

    You can manually extract the values you want from your Map in your mapStateToProps function:

    const mapStateToProps = (state) => {
      return {
           constraints: state.get('constraints'),
           selectedAmount: state.get('selectedAmount'),
           selectedTerm: state.get('selectedTerm'),
      };
    }
    

    0 讨论(0)
提交回复
热议问题