在我的部分,我有以下几点:Redux Form,如何从组件状态设置InitialValue?
componentWillReceiveProps(nextProps) {
if (nextProps.industries.items.length > 0) {
this.setState({
industry_item_id : nextProps.industries.items.find(el => el.title === "XXXX").id
});
}
那么我想在我的终极版形式的初值使用这个值,像这样:
myForm = reduxForm({
form: 'myForm',
initialValues: {
industry_id: this.state.industry_item_id
},
})(myForm);
...
export default connect(mapStateToProps, mapDispatchToProps)(myForm);
我如何使用this.state的initialValues内?另外,this.state.industry_item_id没有在ComponentMount上定义,当this.state.industry_item_id的值设置为componentWillReceiveProps(nextProps)
时,它是否会工作?由于
通知你,我用“终极版形式”:“^ 6.6.3”,
工作得很好。谢谢 – AnApprentice