nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 699 forks source link

example code got error #1623

Closed leonyhenn closed 5 years ago

leonyhenn commented 5 years ago

Object is not a constructor (evaluating 'new _reactNativeMapboxGl.default(_config.default.get('accessToken'))')

So, following is what I did: 1.I copied all the code of src folder to root folder in order to directly run example

  1. Sign up with mapbox, got an accessToken
  2. create a env.json on my project root dir, put
    {
    "accessToken":"my access token"
    }

    in to it

then when I run it on ios, and android it complains about following:

Object is not a constructor (evaluating 'new _reactNativeMapboxGl.default(_config.default.get('accessToken'))')

Not sure what is going on, and no one ever brought this on issues before. I check access token it is still in mapbox website

leonyhenn commented 5 years ago

OK, i have it figured out, this is actually my stupid mistake.

in MapboxClient.js I change

import MapboxClient from 'mapbox';

to

import MapboxClient from '@mapbox/react-native-mapbox-gl';

cause when compailer is complaining I thought this refers to local module and author right it this way only for convinient.

solution: change it back, then run

npm install mapbox

on your root directory

Now things works. I leave it here so if anyone else run into this error can see the solution.