何らかの理由で、匿名関数を使用してコンポーネントを定義すると、値が送信ハンドラに渡されることはありません。呼ばれ、コンソールは、タイトルフィールドの値を表示しますが、カテゴリの値ではない(e)に提出した場合redux-formのsubmit関数で値が渡されない6.0.5
class TestForm extends Component {
constructor(props) {
super(props);
}
submit(e) {
console.log(e);
}
renderField(field) {
return (
<input {...field.input} type="text" className="form-control" placeholder={field.placeholder} />
);
}
render() {
const handleSubmit = this.props.handleSubmit;
return (
<form onSubmit={handleSubmit(this.submit)}>
<div className="form-group">
<label>Title</label>
<Field name="title"
placeholder="Title"
component={this.renderField} />
</div>
<div className="form-group">
<label>Category</label>
<Field name="category"
placeholder="Category"
component={category => (
<input type="text" className="form-control" {...category}/>
)
} />
</div>
<button type="submit" className="btn btn-primary">Submit</button>
</form>
);
}
}
:私は、私は以下のような簡単なフォームを作成しReduxのフォームに6.0.5
を使用しています表示されます。
カテゴリフィールドに私の匿名関数に問題がありますか、またはコンポーネントとしてサポートされていない匿名関数ですか?