私はredux-formを使用しています。initialize
メソッドとcomponentDidUpdate()
メソッドを追加した後で、入力の中に入力できません。自分のメールアドレスに入力しようとすると、文字は表示されません。私はすべての入力が制御されていると推測していますか?もしそうなら、私はそれをどのように扱いますか?フィールドに入力できないのはなぜですか?
import { reduxForm, Field, initialize } from 'redux-form';
const CustomComponent = function(field) {
return(
<div>
<input { ...field.input } type={field.type} placeholder={field.placeholder} />
</div>
);
}
//class instantiation
componentDidUpdate(){
this.handleInitialize();
}
handleInitialize() {
const initData = {
"name": this.props.name
};
this.props.initialize(initData);
}
render() {
const { handleSubmit } = this.props;
return (
<div>
<form onSubmit={handleSubmit(this.onSubmit)}>
<div>
<Field name="name" component={CustomComponent} type="text" placeholder="Name" />
<Field name="email" component={CustomComponent} type="email" placeholder="Email" />
</div>
<button type="submit">Submit</button>
</form>
</div>
);
}
CustomComponentにdivラッパーなしの入力を返そうとしましたか? – Andrew
それは動作しません。同じ問題 – joethemow
@マークフィッツジェラルドあなたが投稿した質問への回答は、私がすでに質問を投稿する前にそれを実装しているので適用されません。 – joethemow