[英]Why is React Redux Form, not passing the formState for SELECT options?
Below is a relevant code snippet. 以下是相关的代码段。 I'm using redux form to render a Select Field... When the field renders, when you change the select option, the form's state is never changed.
我正在使用redux表单呈现选择字段...当呈现字段时,当您更改选择选项时,表单的状态永远不会改变。
console.log(this.props.formState)
The above always renders as undefined. 上面的内容始终呈现为undefined。 What am I doing wrong?
我究竟做错了什么?
let SelectGroup = ({input, title, label, type, defaultOption, options, meta: {touched, error, pristine}}) =>
<select>
{options.map(o =>
<option key={o.id} value={o.id}>{o.title}</option>
)}
</select>
render() {
console.log(this.props.formState)
....
<Field
component={ SelectGroup }
name={ 'industry_id' }
title={ 'industry_id' }
options={ this.props.industries }
/>
}
}
PlacePage = reduxForm({
form: 'PlacePageForm',
validate,
})(PlacePage);
const selector = formValueSelector('PlacePageForm')
const mapStateToProps = state => {
return {
formState: getFormValues('PlacePageForm')(state),
selected_industry_id: selector(state, 'industry_id'),
....
};
};
export default connect(mapStateToProps)(PlacePage);
The issue was solved by changing: 该问题已通过更改解决:
<select>
to: 至:
<select {...input}>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.