私は反応するのが初めてです。フラグに基づいて1つのエラーメッセージを表示/非表示にしたいです。
電卓コンポーネント内
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 であるため、エラーが発生します。この問題が発生する理由がわかりません。