私はReactJSで認証システムを作っており、Reduxストアを使っています。私のSigninクラスを実装している間は、コンソールにが定義されていません。が未定義です。私はsignin.jsファイルと以下のレデューサーファイルを含んでいます。サインインコンポーネントはconsole.logでundefinedを返します
SRC /コンポーネント/ AUTH/signin.js
import React, { Component } from 'react';
import { reduxForm } from 'redux-form';/*
import * as actions from '../../actions';*/
class Signin extends Component {
handleFormSubmit({ email, password }){
/*actions.signinUser({ email, password });*/
console.log(email,password);
}
render() {
// code
const { handleSubmit, fields: { email, password }} = this.props;
return (
<form onSubmit={handleSubmit(this.handleFormSubmit.bind(this))}>
<fieldset className="form-group">
<label>Email:</label>
<input {...email} className="form-control" />
</fieldset>
<fieldset className="form-group">
<label>Password:</label>
<input {...password} className="form-control" />
</fieldset>
<button action="submit" className="btn btn-primary">Sign In</button>
</form>
);
}
// methods
}
export default reduxForm({
form: 'signin',
fields: ['email', 'password']
})(Signin);
SRC /減速/ index.js
import { combineReducers } from 'redux';
import { reducer as form } from 'redux-form';
const rootReducer = combineReducers({
form
});
export default rootReducer;
コンソール
undefined, undefined
'handleFormSubmit'は[**イベントオブジェクト**](https://facebook.github.io/react/docs/events.html)に渡されます。イベントオブジェクトには 'email'と' password'プロパティはありません。したがって、あなたが得ている出力が期待されます。入力フィールドの値を取得する場合は、[被制御コンポーネント](https://facebook.github.io/react/docs/forms.html)を使用します。 –