Skip to content
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

Nextjs #97

Open
murrayleysrgu opened this issue Jul 8, 2023 · 1 comment
Open

Nextjs #97

murrayleysrgu opened this issue Jul 8, 2023 · 1 comment

Comments

@murrayleysrgu
Copy link

Is it possible to use this with Next.js?

I tried to follow the react example but got the following error

error Error [ReferenceError]: window is not defined
at Object. (/Users/ml/Development/Sites/ga-scheduler/node_modules/dhtmlx-gantt/codebase/dhtmlxgantt.js:13:218)

is there a working example with the latest version of Next?

@gearcoded
Copy link

@murrayleysrgu, by default, Next.js runs the code with the server-side rendering. You cannot run Gantt that way as it is a client-side application and requires the Window object and DOM.
You will need to add the following line to the page with the Gantt configuration:

"use client";

https://nextjs.org/docs/getting-started/react-essentials#the-use-client-directive

Here are the demos:
https://files.dhtmlx.com/30d/5c0514c86ca9898058d2fc64bdfc8259/nextjs+GanttInstance-alternative.zip
https://files.dhtmlx.com/30d/27c23572db2101a749a3168d1e8b7917/nextjs+GanttInstance.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants