形成 react-native-elements 的组件导致 "Invariant Violation" 错误
forms component of react-native-elements cause "Invariant Violation" error
我正在使用指示的示例 here
但它抛出 Invariant Violation: element Type is invalid: expected a string
错误页面。
Button 组件工作正常,但不知何故 Forms 组件导致了这个问题,
有人以前使用过 react-native-elements 的表单组件并且知道如何修复它吗?
此处代码:
import React, { Component } from 'react';
import { View, Text,StyleSheet } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import { Input, Button, FormLabel, FormInput, FormValidationMessage } from 'react-native-elements';
class Login extends Component {
constructor(props) {
super(props);
this.state = {
};
}
Login = ()=>{
}
onChangeText=()=>{
}
render() {
return (
<View style={styles.container}>
<View style={styles.headerContainer}>
<Text> Login Page </Text>
</View>
<View style={styles.inputContainer}>
<FormLabel>Name</FormLabel>
</View>
<View style={styles.buttonContainer}>
<Button
large
icon={{name: 'key', type: 'octicon', buttonStyle: styles.someButtonStyle }}
title='Oturum Aç' onPress={()=>this.Login()} />
</View>
</View>
);
}
}
package.json:
"dependencies": {
"react": "16.6.3",
"react-native": "0.57.8",
"react-native-elements": "^1.0.0-beta7",
"react-native-vector-icons": "^6.1.0"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.48.5",
"react-test-renderer": "16.6.3"
},
您使用的是哪个版本的 react-native-elements?我以前见过这个错误,它与使用安装的 react-native-elements 版本不支持的组件有关。
我看到您同时导入了 Input 和 FormLabel,但我相信 Input 仅在 v1.0.0 beta 版本中受支持,而 FormLabel 在 v1.0.0 beta 中不再受支持。
我正在使用指示的示例 here
但它抛出 Invariant Violation: element Type is invalid: expected a string
错误页面。
Button 组件工作正常,但不知何故 Forms 组件导致了这个问题,
有人以前使用过 react-native-elements 的表单组件并且知道如何修复它吗?
此处代码:
import React, { Component } from 'react';
import { View, Text,StyleSheet } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import { Input, Button, FormLabel, FormInput, FormValidationMessage } from 'react-native-elements';
class Login extends Component {
constructor(props) {
super(props);
this.state = {
};
}
Login = ()=>{
}
onChangeText=()=>{
}
render() {
return (
<View style={styles.container}>
<View style={styles.headerContainer}>
<Text> Login Page </Text>
</View>
<View style={styles.inputContainer}>
<FormLabel>Name</FormLabel>
</View>
<View style={styles.buttonContainer}>
<Button
large
icon={{name: 'key', type: 'octicon', buttonStyle: styles.someButtonStyle }}
title='Oturum Aç' onPress={()=>this.Login()} />
</View>
</View>
);
}
}
package.json:
"dependencies": {
"react": "16.6.3",
"react-native": "0.57.8",
"react-native-elements": "^1.0.0-beta7",
"react-native-vector-icons": "^6.1.0"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.48.5",
"react-test-renderer": "16.6.3"
},
您使用的是哪个版本的 react-native-elements?我以前见过这个错误,它与使用安装的 react-native-elements 版本不支持的组件有关。
我看到您同时导入了 Input 和 FormLabel,但我相信 Input 仅在 v1.0.0 beta 版本中受支持,而 FormLabel 在 v1.0.0 beta 中不再受支持。