React Native undefined 不是对象(求值'Mapbox.GL.UserTrackingModes')

React Native undefined is not an object (evaluating 'Mapbox.GL.UserTrackingModes')

我开始使用 mapbox 来响应本机,但是,我在使用 npm 或 yarn 安装它以及导入到我的项目时遇到了这个问题,我有点确定这是否是 mapbox 的问题api 或者我试图实现它的方式是错误的。

使用本机版本:

本机反应:0.57.3

Map.js

import React from 'react'; 
import { StyleSheet, Text, View, Image, StatusBar, ScrollView, TouchableOpacity } from 'react-native';
import Mapbox from '@mapbox/react-native-mapbox-gl';

Mapbox.setAccessToken('mapbox-api-key');

class MapScreen extends React.Component {

   constructor(props) {
    super(props);
    this.state = {

    };
  }

  render() {
    return (
        <View style={styles.container}>
        <StatusBar
            backgroundColor={'transparent'}
            translucent/>
            <Mapbox.MapView
                styleURL={Mapbox.StyleURL.Street}
                zoomLevel={15}
                centerCoordinate={[11.256, 43.770]}
                style={styles.container}>
            </Mapbox.MapView>
        </View>
    );
  }
}


export default MapScreen;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#EFF2F5',
  },
  content: {
    flex: 1,
    flexDirection: 'column',
    alignItems: 'center',
    marginLeft: 40,
    marginRight: 40,
    marginBottom: 30,
  },
  navBar: {
    height: 55,
    backgroundColor: '#fff',
    elevation: 3,
    paddingHorizontal: 15,
    flexDirection: 'row',
    alignItems:'center',
    justifyContent: 'space-between'
  },
  rightNav: {
    flexDirection: 'row'
  },
  navItem: {
    marginLeft: 100
  },
});

确保您正确设置了 android gradle 文件的依赖关系