【发布时间】:2019-06-03 04:47:45
【问题描述】:
我正在使用 React 学习 Redux。我正在使用dispatch,如下所示
this.props.dispatch(uploadImage(formData, config, element_id));
我的mapStateToProps 如下所示
const mapStateToProps = state => ({
uploadImage: state.addressReducer.uploadImage
});
export default connect(mapStateToProps)(ModalElement);
我想得到如下输出
componentWillReceiveProps(nextProps) {
if (nextProps.uploadImage) {
this.setState({ photostatus: 'image' });
console.log(this.state.photostatus) // getting wrong output, not `image`
}
}
这是我的回购https://github.com/afoysal/mern/blob/master/client/src/components/ModalElement.js
【问题讨论】:
标签: redux react-redux