-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot import in next js #118
Comments
How can I fix this? |
Here's a code
|
You need to dynamically import VectorMap as it is unable to be rendered server side. Here is how I have it running in a project. import dynamic from 'next/dynamic';
import worldMill from '@react-jvectormap/world/worldMill.json';
const VectorMap = dynamic(
// @ts-ignore
() => import("@react-jvectormap/core").then((m) => m.VectorMap),
{ ssr: false, }
);
export const Jmap = ({ series }: any) => {
return (
<div>
<VectorMap
map={worldMill}
series={series}
/>
</div>
);
} |
Thank you! Heads up for other devs: I have imported worldMill by destructuring command |
This is a simpler dynamic import that works for me on Next 15.1
@viriyxh you should close this ticket though, not really a bug in this lib. |
Server Error
ReferenceError: self is not defined
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
Object.<anonymous>
file:///Users/macbook-pro/project/frontend/node_modules/@react-jvectormap/core/dist/index.js (18:4)
Module._compile
node:internal/modules/cjs/loader (1097:14)
Object.Module._extensions..js
The text was updated successfully, but these errors were encountered: