undefined 不是函数 - react redux

undifined is not a function- react redux

我在遵循教程 react-native-redux.I 的代码中遇到了一些问题,必须根据我的 Android 更改一些 build.gradle 编译器版本以适应SDK Version.Please 谁能指出我哪里做错了?

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="example@user.com"
                    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;
 }

}

connect 函数不是 react-redux 的默认导出。你必须像这样导入它:

import {connect} from 'react-redux';