Javascript redux表单无法读取属性';任何';未定义的
我对Javascript redux表单无法读取属性';任何';未定义的,javascript,reactjs,react-native,redux-form,Javascript,Reactjs,React Native,Redux Form,我对react native中的redux有问题。我想为我的应用程序实现一个登录表单。从网上的教程中,我写了这段代码,但遇到了这个错误 无法读取未定义的属性“any” Package.json "dependencies": { "react": "16.2.0", "react-addons-update": "^15.6.2", "react-native": "0.53.0", "react-redux": "^5.0.6", "redux": "
react native
中的redux有问题。我想为我的应用程序实现一个登录表单。从网上的教程中,我写了这段代码,但遇到了这个错误
无法读取未定义的属性“any”
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);
看起来该版本的redux表单
不支持react 16。道具类型已移动到单独的包中。尝试将redux表单升级到5.3.6或更高版本
import update from "react-addons-update";
import { combineReducers } from "redux";
import { reducer as formReduser } from "redux-form";
module.exports = combineReducers({
form: formReduser
})