在我的部分,我有以下幾點: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