私のreduxフォームのtouchプロパティにアクセスしようとしていますが、何らかの理由でフィールドpropsを印刷するとオブジェクトの代わりに値のみが表示されます。私は何が欠けていますか?なぜreduxフォームはオブジェクトではなく文字列を返しますか?
import { reduxForm, Field } from 'redux-form';
render() {
const { fields: { email, phone }, handleSubmit } = this.props;
console.log(email) //prints just the value "email" instead of the field object with the touched method, etc. When I do console.log(email.touched) I get undefined error.
return (
<form onSubmit={handleSubmit(this.onSubmit)}>
<Field name="email" component="input" type="email" { ...email } />
<Field name="phone" component="input" type="number" { ...phone } />
</form>
);
}
export default ReduxFormTest = reduxForm({
form: 'uniqueForm',
fields: ['email', 'phone']
})(TestClass);
これは機能しますが、入力に1文字入力すると非アクティブになり、入力を続行するにはもう一度クリックする必要があります。 – joethemow
私はあなたがfield.meta.touched行を編集したのを見ましたが、私はまだそれを追加していないので、問題はそれにありません。 – joethemow
上記の問題は、入力しようとする最初のフィールドでのみ発生します。 – joethemow