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