我在redux-from
中遇到react-native
的问题。我想为我的应用程序实现登录表单。从我在网上的教程我写了这个代码,但有这个错误的问题
无法阅读财产'任何'未定义的
的package.json
"dependencies": {
"react": "16.2.0",
"react-addons-update": "^15.6.2",
"react-native": "0.53.0",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-form": "^5.3.2",
"redux-persist": "^3.2.2"
},
这是我的 Login.js 组件
import React, { Component } from 'react';
import { StyleSheet, Text, View, TextInput, TouchableOpacity } from 'react-native';
import { reduxForm } from "redux-form";
class Login extends Component {
onSignIn() {
var { email, password } = this.props.fields;
console.log(email.value, password.value);
}
render(){
var {fields: {email, password}} = this.props;
return (
<View style={styles.container}>
<View style={styles.titleContainer} >
<Text style={styles.title} >ToDo</Text>
</View>
<View style={styles.fields} >
<TextInput
{...email}
placeholder="Email"
style={styles.TextInput}
/>
</View>
<View style={styles.fields} >
<TextInput
{...password}
placeholder="Password"
style={styles.TextInput}
/>
</View>
<View style={styles.buttonContainer} >
<TouchableOpacity>
<Text style={styles.button} onPress={this.onSignIn} >
Signin
</Text>
</TouchableOpacity>
<TouchableOpacity>
<Text style={styles.button}>
Signup
</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
...
});
var validate = (formProps) => {
var errors = {};
return errors;
}
export default reduxForm({
form: 'login',
fields: ['email', 'password'],
validate: validate
}, null, null)(Login);
我的减速机 index.js
import update from "react-addons-update";
import { combineReducers } from "redux";
import { reducer as formReduser } from "redux-form";
module.exports = combineReducers({
form: formReduser
})
答案 0 :(得分:3)
看起来redux-form
的版本不支持反应16.支持类型已移至单独的包中。尝试将redux-form
升级到5.3.6或更高版本。