Using ReactMapboxGl with next.js (isomorphic)
See original GitHub issueI’m new to react and am trying to string together ReactMapboxGl with Next.js and it errors onload as ReactMapboxGl can’t load server side (errors with ReferenceError: self is not defined
) but then works on subsequent hot reloads.
I’ve tried using require()
within componentDidMount
but get an error like this
Module build failed: TypeError: /components/mapLoader.js: Property name of JSXOpeningElement expected node to be of a type ["JSXIdentifier","JSXMemberExpression"] but instead got "Identifier"
I’m sure there’s just something up with my implementation but I am struggling to work out why? My whole repo is here — https://github.com/jonheslop/colwiki/
Any tips would be greatly appreciated, thanks 😄
Issue Analytics
- State:
- Created 7 years ago
- Comments:24
Top Results From Across the Web
Using mapbox-gl in React with Next.js - DEV Community
First of all, let's create a new project in Next.js using the Typescript template. npx create-next-app --typescript my-awesome-app.
Read more >Build Isomorphic Apps with Next.js - JScrambler Blog
In this tutorial, we'll build a simple timer component in React that is isomorphic and leverages Next.js for universal rendering.
Read more >React map library comparison - LogRocket Blog
This post provides an overview of several existing React map libraries and compares each based on functionality and ease of use.
Read more >react-mapbox-gl Features don't work with NextJS
I'm trying to use react-mapbox-gl with NextJS. Just trying to get the demo working, a map with a single Feature.
Read more >shengtaii/awesome-react - Gitee
next.js - The React Framework; gatsby.js - Free and open source framework based ... Isomorphic google map React component; react-mapbox-gl - A mapbox-gl-js ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also stumbled on this and ended up writing a blog post on how to use Mapbox with Next.js.
You can find a working example and full code here.
I think it can be resolved with dynamic imports now - see https://github.com/zeit/next.js#dynamic-import