vasturiano / react-globe.gl

React component for Globe Data Visualization using ThreeJS/WebGL
https://vasturiano.github.io/react-globe.gl/example/world-population/
MIT License
818 stars 150 forks source link

Next js Errors #167

Open DENNIS-CODES opened 6 months ago

DENNIS-CODES commented 6 months ago

image

first error is importing the module no longer works when imported as such

const Globe = dynamic( () => import('react-globe.gl').then((mod) => mod.default), { ssr: false } ); quick fix here was encapsulating the component with the package react-no-ssr import NoSSR from "react-no-ssr";

<NoSSR>
      <GlobeComponent />
</NoSSR>

after the first error is solved the component on initial load

second error if you happen to reload the page image

the quick fixes available wether you use

packages version am using

node latest

To avoid falling to the pitfalls of react you can easly focus on next on this two issues

DENNIS-CODES commented 6 months ago
let Globe = () => null
if (typeof window !== 'undefined') Globe = require('react-globe.gl').default

this solve the error in next about importing and window undefined