0

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

在计算器组件中

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

并通过 connect 连接

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 is not a function 。我不明白为什么会出现这个问题。

4

0 回答 0