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

Nuxt3 throws "window is not defined" error in SSR context #57

Closed
thplat opened this issue Feb 27, 2022 · 1 comment
Closed

Nuxt3 throws "window is not defined" error in SSR context #57

thplat opened this issue Feb 27, 2022 · 1 comment

Comments

@thplat
Copy link

thplat commented Feb 27, 2022

Description of the bug
In Nuxt3 the useClickAway composable throws an error within an SSR context: window is not defined.

The error occurs here:

  if (!window) {
    return;
  }

however I have no idea why Nuxt complains here since the expression !window should just evaluate to a thruthy value and therefore just process the if-statement.

The following will fix the issue:

  if (typeof window !== 'undefined' || !window) {
    return;
  }

I will submit a PR

@valgeirb
Copy link
Owner

valgeirb commented Mar 4, 2022

Fixed in v1.4.2

@valgeirb valgeirb closed this as completed Mar 4, 2022
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