// 我正在比较成功提交表单后reducer的响应。获得成功响应后如何将alert设置为true。
componentDidUpdate(prevProps) {
if (this.props.tempData!==prevProps.tempData) {
this.setState(() => this.setState({ alert: true }));
}
}
const mapStateToProps = state => {
return { tempData: state.CourseReducer['result'] };
};
export default connect(mapStateToProps, { postRetriver })(
TextField
);
//reducer
export const CourseReducer = (state = {}, action) => {
if (action.type === 'SET_COURSE') {
// console.log(action.payload)-->{status: 200, data: "Updated Successfully"}
return { ...state, "result":action.payload };
}
return state;
};