在我的本机redux格式代码中,我遇到了这类奇怪的问题。 对此有什么解决方案,请参见以下代码片段。 有任何库版本错误吗?还是我的代码有误? 我的代码中没有发现任何错误。
Chrome中的调试器:
Cannot read property 'displayName' of undefined
handleException @ ExceptionsManager.js:74
handleError @ setUpErrorHandling.js:23
reportFatalError @ error-guard.js:42
guardedLoadModule @ require.js:199
metroRequire @ require.js:125
(anonymous) @ createValues.js:35
executeApplicationScript @ debuggerWorker.js:40
(anonymous) @ debuggerWorker.js:72
这是App.js
App.js
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import LoginForm from './LoginForm';
import store from './Store';
export default class App extends Component{
render() {
return (
<Provider store={store}>
<LoginForm />
</Provider>
);
}
}
这是LoginForm.js
LoginForm.js
import React from 'react';
import { StyleSheet, Alert, TouchableHighlight, TextInput, View, Text } from 'react-native';
import { reduxForm } from 'redux-form'
const LoginForm = reduxForm({
form: 'LoginForm'
})(MyFormComponent);
const MyFormComponent = () => {
return (
<View style={styles.container}>
<Text style={styles.title}>Login</Text>
<View style={styles.combineview}>
<Text>First Name :</Text>
<TextInput
underlineColorAndroid="black"
placeholder="First Name" />
<Text>Surname :</Text>
<TextInput
placeholder="Surname"
underlineColorAndroid="black" />
<Text>Email :</Text>
<TextInput
placeholder="Email"
underlineColorAndroid="black" />
<TouchableHighlight
style={styles.button}
onPress={() => Alert.alert('Button clicked')}>
<Text> Add </Text>
</TouchableHighlight>
</View>
</View>
);
}
export default LoginForm;
这是store.js
Store.js
import {createStore, combineReducers} from 'redux';
import {reducer as formReducer} from 'redux-form';
const mainReducer = combineReducers({
form: formReducer
});
const store =createStore(mainReducer)
export default store;