【发布时间】:2020-04-25 14:17:01
【问题描述】:
我是新来的反应并尝试创建在应用程序上显示的地图元素。但是,当我说我正在导出默认类 App 时,我相信我做错了。这是我得到的错误“React.createElement: type is invalid -- 期望一个字符串(用于内置组件)或一个类/函数(用于复合组件)但得到:“未定义””我的代码如下。
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { MapView } from 'expo';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
region: {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.922,
longitudeDelta: 0.0421,
}
}
}
render() {
return (
<View style={styles.container}>
<Text>Home Sreen</Text>
<MapView
initialRegion={this.state.region}
showsCompass={true}
rotateEnabled={false}
style={{flex: 1}}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
});
【问题讨论】:
-
你是如何导入和渲染App的?
-
检查this
标签: javascript reactjs react-native