调度操作是投掷错误(React-Redux)

时间:2018-03-06 07:15:06

标签: javascript reactjs react-router react-redux redux-actions

我是新手做出反应,我想根据标志显示/隐藏一条错误消息。

在计算器组件

handleDealSizeChange({ target }){
  this.setState({
    [target.name]: target.value,
    dealType: 'patient'
  });
  this.props.doSearchClick(this.state.patientDealSize);
}

通过连接

连接
function mapStateToProps(state) {
  const { patientDealSize='', dealType='' } = state;
  console.log("state" , state);
  return {
  patientDealSize,
  dealType
}

}

function mapDispatchToProps(dispatch){
  return {
    doSearchClick: (someName) =>{
      dispatch(setDealSize(someName))
    }
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(Calculator);

在行动中

const setDealSizeSucess = (patientDealSize) =>{
    return {
        type: 'SET_DEAL_SIZE_SUCCESS',
        patientDealSize
    }
}

export const setDealSize = (patientDealSize) => dispatch => {

   dispatch(setDealSizeSucess(patientDealSize))
    .catch((err) => {
        console.log(err);
    });
}

我收到错误,因为Uncaught TypeError:dispatch(...)。catch不是函数。我不明白为什么会出现这个问题。

0 个答案:

没有答案