dataarts / dat.gui

Lightweight controller library for JavaScript.
Apache License 2.0
7.46k stars 1.08k forks source link

Error: window is not defined #305

Closed irwansyafani closed 3 years ago

irwansyafani commented 3 years ago

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?

tomhsiao1260 commented 3 years ago

I think you can try the following syntax instead.

import * as dat from 'dat.gui'
irwansyafani commented 3 years ago

I think you can try the following syntax instead.

import * as dat from 'dat.gui'

still not working

tomhsiao1260 commented 3 years ago

I found that there are already some discussions. Maybe it will help. https://github.com/dataarts/dat.gui/issues/271

irwansyafani commented 3 years ago

Problem solved, Thanks Tom!

woshitiancai5686 commented 4 months ago

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

})