ReactJS:如何在 redux-form 字段中包装 react-select? [英] ReactJS: How to wrap react-select in redux-form field?

查看:30
本文介绍了ReactJS:如何在 redux-form 字段中包装 react-select?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 react-select 库并面临一些问题,我正在使用 redux-form 库并导入 <Field/>组件来自它.这样我就可以通过表单将值提交给服务.

当我使用 react-select 中的默认 组件并与

从'react'导入React;导入从反应选择"中选择;从'./RenderSelectInput'导入RenderSelectInput;//我的自定义选择框var options = [{ value: 'one', label: 'one' }, { value: 'two', label: 'Two' }];class SelectEx 扩展了 React.Component {构造函数(){极好的();this.state = { selectValue: 'sample' }this.updateValue = this.updateValue.bind(this);}更新值(新值){this.setState({ selectValue: newValue })}使成为() {返回 (<div><选择名称="select1" id="selectBox" value={this.state.selectValue} options={options} onChange={this.updateValue}/>//这有效,但值不会提交...<Field name="sample" component={RenderSelectInput} id="sampleEX" options={options}/>//为此,一旦我从组件中出来,选定的值就会消失.

)}}导出默认 SelectEx;

但是当我使用我的自定义选择(我正在包装提交表单中的值)时,

发送“验证码”获取 | 15天全站免登陆