[英]React.createElement: type is invalid (map)
I am new to react and trying to create a map element that shows on the app.我刚开始反应并尝试创建一个显示在应用程序上的地图元素。 However I believe I am doing something wrong when I say I am exporting the default class App.
但是,当我说我正在导出默认类 App 时,我相信我做错了什么。 This is the error I get "React.createElement: type is invalid -- expected a string (for built in components) or a class/function (for composite components) but got: "undefined"" I have my code below.
这是我得到的错误“React.createElement:类型无效——需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:“未定义””我在下面有我的代码。
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',
},
});
Instead of代替
import { MapView } from 'expo';
use用
import MapView from 'react-native-maps';
尝试从类中删除导出默认值并将其添加到程序的最后一行
Export default appname;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.