2016-12-03 3 views
0

私はこのコードでいくつかの問題を抱えています。これは私がチュートリアルreact-native-reduxに従っています。build.gradleコンパイラのバージョンをAndroid SDKのバージョンに合わせて変更しなければなりませんでした。誰が私が間違いを犯したのかを指摘できますか?undifinedは関数ではありません。

enter image description here

import React, { Component } from 'react'; 
import { View, Text } from 'react-native'; 
import firebase from 'firebase'; 
import connect from 'react-redux'; 
import {emailChanged} from '../actions'; 
import { Spinner, Header, Button, Card, CardSection, Input } from './common'; 


class LoginForm extends Component { 

// constructor() { 
//  super(); 
//  this.onEmailChange = this.onEmailChange.bind(this); 
// } 

onEmailChange(text) { 
    //step 1 : trigger the action with new text 
    this.props.emailChanged(text); 
} 

render() { 
    return (
     <Card> 
      <CardSection> 
       <Header text="Please Login" /> 
      </CardSection> 
      <CardSection> 
       <Input placeholder="[email protected]" 
        labelText="e Mail" 
        onChangeText={this.onEmailChange.bind(this)} 
        //set the value with previous text 
        value={this.props.email} 
        /> 

      </CardSection> 
      <CardSection> 

       <Input encrypt={true} labelText="Password" /> 
      </CardSection> 
      <CardSection> 
       <Button>Login Here</Button> 
      </CardSection> 

     </Card> 
    ); 
    } 

}; 

// get the state(session) and assign to props 
const mapStateToProps = (state) => { 
    return { 
    //return empty objetc with assigned session.reducerName.propertyName as props 
    email : state.auth.email 
    }; 
}; 


export default connect(mapStateToProps,{emailChanged})(LoginForm); 

アクション

import Types from './types'; 

export const emailChanged = (text) => { 
    return { 
    type : Types.EMAIL_CHANGED , 
    payload : text 
    }; 
}; 

リデューサー

import Types from '../actions/types'; 

const INITIAL_STATE = { email: '' }; 

export default (state = INITIAL_STATE, action) => { 
switch (action.type) { 

    case Types.EMAIL_CHANGED: 
     //need a brand new object when returning - Theory 
     // return an empty object with all properties of state with email updated with action.payload 
     return { ...state, email: action.payload }; 

    default: 
     return state; 
} 

} 
+0

ます場合、私はあなたが、経験則として –

答えて

1

connect機能はreact-reduxのデフォルトのエクスポートではありません。あなたはこのようにそれをインポートする必要があります。

import {connect} from 'react-redux'; 
+0

のコンストラクタでコメント行を削除します「未定義ではない...」というエラーがあり、あなたの輸入品を見てください。」:D。喜んで助けてくれました! – Azela

+0

that.youがtrouble.Thankの日から私を救っ逃す可能性がどのようにはいおおloginform – martinarroyo

関連する問題