In my component, I have the following:
componentWillReceiveProps(nextProps) {
if (nextProps.industries.items.length > 0) {
this.setState({
industry_item_id : nextProps.industries.items.find(el => el.title === "XXXX").id
});
}
I then want to use this value in my Redux Form's initialValue like so:
myForm = reduxForm({
form: 'myForm',
initialValues: {
industry_id: this.state.industry_item_id
},
})(myForm);
...
export default connect(mapStateToProps, mapDispatchToProps)(myForm);
How can I use this.state within the initialValues? Also, this.state.industry_item_id is not defined on ComponentMount, will this work when the value of this.state.industry_item_id is set with componentWillReceiveProps(nextProps)
?
I'm using "redux-form": "^6.6.3"
.