I am learning Redux with React. I am using dispatch
like below
this.props.dispatch(uploadImage(formData, config, element_id));
My mapStateToProps
is like below
const mapStateToProps = state => ({
uploadImage: state.addressReducer.uploadImage
});
export default connect(mapStateToProps)(ModalElement);
I would like to get output like below
componentWillReceiveProps(nextProps) {
if (nextProps.uploadImage) {
this.setState({ photostatus: 'image' });
console.log(this.state.photostatus) // getting wrong output, not `image`
}
}
Here is my Repo https://github.com/afoysal/mern/blob/master/client/src/components/ModalElement.js