guiqui / react-timeline-gantt

A react Timeline component with virtual rendering
MIT License
536 stars 130 forks source link

ReferenceError: window is not defined #61

Open KatyHwang opened 3 years ago

KatyHwang commented 3 years ago

I am using the nextjs , the chart cannot show .

error msg:

Server Error ReferenceError: window is not defined

This error happened while generating the page. Any console logs will be displayed in the terminal window. Source external%20%22react-gantt-timeline%22 (1:0) @ Object.react-gantt-timeline

1 | module.exports = require("react-gantt-timeline"); Call Stack __webpack_require__ webpack\bootstrap (21:0) Show collapsed frames 擷取

KatyHwang commented 3 years ago

ReferenceError: window is not defined at Object. (C:\Users\katy\source\react\shipDemo\node_modules\react-gantt-timeline\dist\index.js:1:421)

kdoroszewicz commented 3 years ago

I encountered the same problem @KatyHwang. You can work around it by using Dynamic Import:

import dynamic from "next/dynamic";
const TimeLine = dynamic(() => import("react-gantt-timeline"), { ssr: false });