我想将此输入值传递给另一个组件状态。为了清楚起见,我希望此redux表单输入的值将其传递给另一个组件的状态。反正有实现吗?
renderTextField(field){
return(
<div className="form-group">
<label>{field.label}</label>
<input
className="form-control"
type="text"
placeholder="Name"
{...field.input}
required
/>
</div>
)
}
render(){
const {handleSubmit}=this.props;
return(
<form style={newrow} onSubmit={handleSubmit(this.onSubmit.bind(this))}>
<Field
label={"Student Name"}
name="name"
component={this.renderTextField}
/>
<Field
label={"Average Grade"}
name="avgGrade"
component={this.renderTextField}
/>
<Field
label={"Curriculum / Occupation"}
name="occupation"
component={this.renderTextField}
/>
<button className="btn btn-primary btn-right">Create</button>
</form>
);
}
}
答案 0 :(得分:0)
redux-form
值以redux状态存储,因此可以像其他任何redux值一样访问它们。它们在form.yourFormName.values.yourInputName
下(假设您将其称为redux-formredizer form
)