Error: window is not defined
irwansyafani opened this issue · 5 comments
irwansyafani 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?
tomhsiao1260 commented
I think you can try the following syntax instead.
import * as dat from 'dat.gui'
irwansyafani commented
I think you can try the following syntax instead.
import * as dat from 'dat.gui'
still not working
tomhsiao1260 commented
I found that there are already some discussions. Maybe it will help.
#271
irwansyafani commented
Problem solved, Thanks Tom!
woshitiancai5686 commented
import('dat.gui').then(dat => {
})