seregazolotaryow64
@seregazolotaryow64
IT Специалист и самоучка

Как запустить Mapbox SDK для React Native без ошибок и предупреждении?

Доброе утро!
В одно из своих мобильных приложении попробовал внедрить Mapbox SDK for RN для отдельного компонента и его код на Typescript:
import React, {Component} from 'react';
import {StyleSheet, View} from 'react-native';
import MapboxGL from '@react-native-mapbox-gl/maps';

type AppProps = {}
type AppState = {}

MapboxGL.setAccessToken('pk.eyJ1Ijoic2VyZWdhem9sb3RhcnlvdzY0IiwiYSI6ImNrdGNuam91cTBlOWMyb3RkMGdleWt0ZW8ifQ.Z9JHSStCgSwJhaaRoLjD9w');

export class NavigatorMap extends Component<AppProps, AppState> {
  coordinates: number[];
  constructor(props: AppProps | Readonly<AppProps>) {
    super(props);
    this.coordinates = [-122.4324, 37.78825];
    this.state = {
    };
  }
  render() {
    return (
      <View style={styles.MainContainer}>
        <View style={styles.SubContainer}>
          <MapboxGL.MapView style={styles.Mapbox}>
            <MapboxGL.Camera
              zoomLevel={9}
              centerCoordinate={this.coordinates}
            />
          </MapboxGL.MapView>
        
        </View>
      
      </View>
    
    );
  }
}
 
const styles = StyleSheet.create({
  MainContainer: {
    flex: 1,
  },
  SubContainer: {
    height: '100%',
    width: '100%',
    backgroundColor: 'white',
  },
  Mapbox: {
    flex: 1,
  },
});


И после начала тестирования компонента на своём Android-смартфоне с помощью Expo Go, компилятор принёс мне вот такие плохие новости:

Android Bundling complete 35728ms
Android Running app on Redmi 8A

Native part of Mapbox React Native libraries were not registered properly, double check our native installation guides.
at node_modules/@react-native-mapbox-gl/maps/javascript/components/MapView.js:25:12 in
at 192.168.1.223:19000/node_modules/expo/AppEntry.bun... in
at 192.168.1.223:19000/node_modules/expo/AppEntry.bun... in
at 192.168.1.223:19000/node_modules/expo/AppEntry.bun... in
at App.tsx:6:0 in
at node_modules/expo/AppEntry.js:3:0 in
at 192.168.1.223:19000/node_modules/expo/AppEntry.bun... in global code

Unable to start your application. Please refer to https://expo.fyi/no-registered-application for more information.
at node_modules/react-native/Libraries/ReactNative/AppRegistry.js:200:6 in runApplication

TypeError: null is not an object (evaluating 'MapboxGL.StyleURL')
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
info
PRO TIP
When you see Red Box with stack trace, you can click any
stack frame to jump to the source file. The packager will launch your
editor of choice. It will first look at REACT_EDITOR environment
variable, then at EDITOR.
To set it up, you can add something like
export REACT_EDITOR=atom to your ~/.bashrc or ~/.zshrc depending on
which shell you use.

Как избавиться от ошибок и предупреждении компилятора и что я пропустил в фрагментах кода? Заранее вам спасибо!
  • Вопрос задан
  • 133 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы