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
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,
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,