Reactjs 在react js中过帐数据时,所选选项值为空

Reactjs 在react js中过帐数据时,所选选项值为空,reactjs,Reactjs,我正在使用react select作为选择下拉列表。我在onchange中获得了所选的选项值。提交注册表单上的数据时,所选选项值始终为空。如何在表单句柄中获取所选选项值,如名称和密码 class addAtribute extends Component { handleFormSubmit({ name, password,role }) { this.props.signup({ name, password, role});

我正在使用react select作为选择下拉列表。我在onchange中获得了所选的选项值。提交注册表单上的数据时,所选选项值始终为空。如何在表单句柄中获取所选选项值,如名称和密码

  class addAtribute extends Component {

        handleFormSubmit({ name, password,role }) {

              this.props.signup({ name, password, role});
       }

  constructor(props){
    super(props);
    this.state={value:''};
   // this.state={};
  }


render(){

    const { handleSubmit, fields: {name, password,role }} = this.props;

    return(
         <form onSubmit={handleSubmit(this.handleFormSubmit.bind(this))}>
            <div className="login" id="login" >
                <div className="col-md-12"> 
                   <input  placeholder="Password" id="pwd" className="login-password form-control" type="password" {...password} />
               <label for="dropdown-custom-1" >Select the Role</label>
                <Select value={this.state.value} options={options} 
                         onChange={event =>                                                                                                       this.setState({value:event.value})} {...role} />       </div>

                                            <button action="submit " className="btn btn-block"><div action="submit" className="login-submit ">Update</div></button>

    );}}


    var options = [
      { value: '1', label: 'Admin'},
      { value: '2', label: 'Manager' },
      { value: '3', label: 'Editor' }];


      function mapStateToProps(state){
           return {auth: state.auth}
      }

       function mapDispatchToProps(dispatch){
           return bindActionCreators({ signup }, dispatch);
       }


         export default reduxForm({
               form: 'signup',
              fields: ['name', 'password','role'},mapStateToProps,mapDispatchToProps)(addAtribute);
类addAtribute扩展组件{
handleFormSubmit({name,password,role}){
this.props.signup({name,password,role});
}
建造师(道具){
超级(道具);
this.state={value:''};
//this.state={};
}
render(){
const{handleSubmit,字段:{name,password,role}}=this.props;
返回(
选择角色
this.setState({value:event.value}}{…role}/>
更新
);}}
变量选项=[
{值:'1',标签:'Admin'},
{值:'2',标签:'Manager'},
{值:'3',标签:'Editor'}];
函数MapStateTops(状态){
返回{auth:state.auth}
}
功能图DispatchToprops(调度){
返回bindActionCreators({signup},dispatch);
}
导出默认reduxForm({
表格:'注册',
字段:['name'、'password'、'role'}、mapStateToProps、mapDispatchToProps)(addAtribute);
您只需编写

<form onSubmit={this.handleFormSubmit.bind(this)}>

您只需编写

<form onSubmit={this.handleFormSubmit.bind(this)}>