0
我在使用React Native基本教程。它结束在此之后,我试图在TextInput tutorial使用的代码添加一个按钮,下面的例子中Button page添加按钮时元素类型无效
import React, { Component } from 'react';
import { AppRegistry, Text, TextInput, Button, View } from 'react-native';
class AwsumProjek extends Component {
constructor(props) {
super(props);
this.state = {tiText: ''};
}
render() {
return (
<View style={{padding: 10}}>
<TextInput
style={{height: 40}}
placeholder="Type here to translate!"
onChangeText={(tiText) => this.setState({tiText})}
/>
<Text style={{padding: 10, fontSize: 42}}>
{this.state.tiText.split(' ').map((word) => word && 'WA').join(' ')}
</Text>
<Button
title="Press Purple"
color="#841584"
accessibilityLabel="Learn more about purple"
/>
</View>
);
}
}
AppRegistry.registerComponent('AwsumProjek',() => AwsumProjek);
相反,我得到这个错误
Element type is invalid: expected a string (for built-in components)
or a class/function (for composite components) but got: undefined.
Check the render method of 'AwsumProjek'.
我做了什么错?看到其他答案,是否与导入内容有关?
我是原生Android开发人员,试图学习React Native,现在和我一样,Javascript对我来说完全陌生。
您是否使用React Native版本0.37?按钮被引入0.37 – vinayr
Ooo rite我仍然使用0.36!谢谢!你能把它作为答案吗? – Konayuki