我想用redux-form
中的this.props.change
改变redux-form V6
的深场。
这是我的mapStateToProps
:
function mapStateToProps(state) {
const {recipient_type, filters} =
formValueSelector('form_wizard')(
state, 'filters.recipient_type' ,'filters');
return {
recipient_type,
filters
}
}
这是我的componentDidMount
(我想以编程方式更改深度字段)
componentDidMount() {
if (!this.props.recipient_type) {
this.props.change("filters.recipient_type}",
someThing);}
}
this.props.recipient_type
的结果未定义。
如何在this.props.change()
中用redux-form
改变深场?
谢谢
最后,我找到了答案
如果要以redux-form访问深字段,则必须使用formValueSelector中的父键获取它:
function mapStateToProps(state) {
const {filters} =
formValueSelector('form_wizard')(
state, 'filters.recipient_type' );
return {
recipient_type : filters,
}
}
如果你需要获得父字段:
function mapStateToProps(state) {
const {filters} =
formValueSelector('form_wizard')(
state, 'filters' );
return {
recipient_type : filters.recipient_type,
}
}