sindresorhus / screenfull

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API
https://sindresorhus.com/screenfull
MIT License
7.08k stars 698 forks source link

Whenever I refresh the page I get "document is not defined" #199

Closed iWanheda closed 2 years ago

iWanheda commented 2 years ago

image

My code is literally:


useEffect(() => {
    if (vidState.fullscreen) {
      if (screenfull.isEnabled) {
        screenfull.request();
      }
    }
  }, [vidState.fullscreen]);```
iWanheda commented 2 years ago

Even if I just import it I get the error, without even using it!

RyanWarner commented 2 years ago

@iWanheda I solved this by downgrading to version 5.1.0

See https://github.com/sindresorhus/screenfull/issues/194

MajorBreakfast commented 2 years ago

The problem also exists when doing SSR in SvelteKit. While screenfull can't offer functionality on the server, it could be inert, and not throw on import.