【发布时间】:2018-06-05 04:01:43
【问题描述】:
我正在使用本机反应在应用程序中构建地图视图。但是当我运行应用程序时出现此错误:
检查'App'的渲染方法
这段代码有什么问题?抱歉,我是 react native 的新手。
App.js
import React, {Component, Fragment} from 'react';
import {
Platform,
StyleSheet,
View,
MapView
} from 'react-native';
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<MapView
style={styles.map}
provider={null}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
},
});
index.js
import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('newapp', () => App);
【问题讨论】:
标签: react-native