dataarts / dat.gui

Lightweight controller library for JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: window is not defined

irwansyafani opened this issue · comments

commented

I'm using Three JS with Next JS and get an error window is not defined after importing dat.gui

here's my code when getting error :

...
import dat from "dat.gui" // dat is not on use yet
// but if "import dat" is commented, the window will run as usual

const MyComponent = () => {

  useEffect(() => {
    const width = window.innerHtml;
  }, [])

  return (
  ...
  )
}

someone, any solution for this issue?

I think you can try the following syntax instead.

import * as dat from 'dat.gui'
commented

I think you can try the following syntax instead.

import * as dat from 'dat.gui'

still not working

I found that there are already some discussions. Maybe it will help.
#271

commented

Problem solved, Thanks Tom!

import('dat.gui').then(dat => {

})