React-mapbox-gl: ReferenceError: self is not defined

Created on 25 Feb 2019  路  2Comments  路  Source: alex3165/react-mapbox-gl

I am getting ReferenceError when simply using Map

   const Map = ReactMapboxGl({
      accessToken: xxxxxx
    });

    <Map style="mapbox://styles/mapbox/light-v9" />

ReferenceError: self is not defined
at node_modules/mapbox-gl/dist/mapbox-gl.js:29:4976
at define (node_modules/mapbox-gl/dist/mapbox-gl.js:22:5)
at node_modules/mapbox-gl/dist/mapbox-gl.js:33:1
at node_modules/mapbox-gl/dist/mapbox-gl.js:3:81

Most helpful comment

You must be used the ServerSide rendering framework.
mapbox is client-side, so you need to make the controller render on client-side only,
If Use Next.js framework, call the component by using next/dynamic with ssr false,

All 2 comments

What was the solution?

You must be used the ServerSide rendering framework.
mapbox is client-side, so you need to make the controller render on client-side only,
If Use Next.js framework, call the component by using next/dynamic with ssr false,

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PawkaHub picture PawkaHub  路  17Comments

alex3165 picture alex3165  路  15Comments

Beeze picture Beeze  路  15Comments

z0d14c picture z0d14c  路  15Comments

pronebird picture pronebird  路  19Comments