2017-06-11 15 views
0

私は、反応型と還元型を使用して簡単なログインフォームを作成しています。 フォームに入力された値をコンソール化しようとすると、定義されません。フォームの値をredux形式で取得できませんか?

import React, { Component } from 'react'; 
    import { reduxForm } from 'redux-form';`enter code here` 

    class Signin extends Component { 
     handleFormSubmit({email, password}){ 
     console.log(email,password); 
     // this.props.signinUser({email,password}); 
     } 

     render(){ 
     const { handleSubmit, fields: { email, password }} = this.props; 

     return (
      <form onSubmit={handleSubmit(this.handleFormSubmit.bind(this))}> 
      <fieldset className="form-group"> 
       <label>Email:</label> 
       <input className="form-control" {...email} /> 
      </fieldset> 
      <fieldset className="form-group"> 
       <label>Password:</label> 
       <input className="form-control" {...password} /> 
      </fieldset> 
      <button action="submit" className="btn btn-primary">Sign in</button> 
      </form> 
     ); 
     } 
    } 

    export default reduxForm({ 
     form: 'signin', 
     fields: ['email', 'password'] 
    })(Signin); 

答えて

1

私は問題を把握しました。

私が従っていたチュートリアルは1年前であり、このフォームで入力を受け入れる古いバージョンのRedux Formを使用していました。しかし、モジュールのインストール中に、私は最新のバージョンをインストールしました。ありがとう。

関連する問題