[英]Why is React Redux Form, not passing the formState for SELECT options?
以下是相關的代碼段。 我正在使用redux表單呈現選擇字段...當呈現字段時,當您更改選擇選項時,表單的狀態永遠不會改變。
console.log(this.props.formState)
上面的內容始終呈現為undefined。 我究竟做錯了什么?
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);
該問題已通過更改解決:
<select>
至:
<select {...input}>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.