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