我正在使用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"
},
答案 0 :(得分:1)
您使用哪个版本的react-native-elements?我之前曾见过此错误,这与使用已安装版本的react-native-elements不支持的组件有关。
我看到您同时导入了Input和FormLabel,但是我相信Input仅在v1.0.0 beta版本中受支持,而FormLabel在v1.0.0 beta中不再受支持。