nextjs 下报 ReferenceError: self is not defined
nshen opened this issue · 3 comments
nshen commented
ReferenceError: self is not defined
at Object.<anonymous> (/home/nn/github/nextV/node_modules/echarts-liquidfill/dist/echarts-liquidfill.js:10:4)
"echarts": "5.1.0",
"echarts-for-react": "^3.0.1",
"echarts-gl": "^2.0.8",
"echarts-liquidfill": "3.1.0",
mysticaltech commented
The same thing is happening to me, but with other libs! I do not yet know how to fix that error.
nshen commented
hi @mysticaltech this is due to ssr ssg relative things, I solved by dynamic import it
// fix ssr error
if (isClient()) {
// @ts-ignore
import('echarts-liquidfill');
}
/**
* nextjs-utils
*/
export function isClient(): boolean {
return typeof window !== 'undefined';
}
mysticaltech commented