Here is my code and the result is none.
import React, {Component} from 'react';
import ReactMapBox from 'react-map-gl';
import 'mapbox-gl/dist/mapbox-gl.css';
class MapExample1 extends Component {
state = {
viewport: {
width: "100vw",
height: "100vh",
latitude: 42.430472,
longitude: -123.334102,
zoom: 16
}
};
render() {
console.log("Entering console.log in MapExample1.js ");
return (
<ReactMapBox
{...this.state.viewport}
onViewportChange={(viewport => this.setState(viewport))}
mapboxApiAccessToken=
'pk.eyJ1Ijoicm95Y2VtYXJ0aW4iLCJhIjoiY2wzODk0bmp3MDc4YjNpbnphNzRzODR1YSJ9.peCCwkWoX_RHseUf2WI1Xw'
/>
);
}
}
export default MapExample1;
But the resulted error is [Error: A valid map box access token is required to use map box GL JS.] in console inspect.
Sadly, Mapbox decided that some of their libraries need to use Mapbox access token for all map views.
This is the case for the famous Mapbox GL JS.
More info could be found at the 2.0.0 release page: https://github.com/mapbox/mapbox-gl-js/releases/tag/v2.0.0
The concrete paragraph where this is stated is this one:
And I believe, based on what I read on react-map-gl GIT page, is the same for that other library, which I think is the one you're using.
The related paragraph on react-map-gl GIT page:
About Mapbox Tokens