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

[V4] ReferenceError: window is not defined #139

Closed
alexw23 opened this issue Jan 30, 2023 · 4 comments
Closed

[V4] ReferenceError: window is not defined #139

alexw23 opened this issue Jan 30, 2023 · 4 comments

Comments

@alexw23
Copy link

alexw23 commented Jan 30, 2023

Recently upgraded to the latest version of this package, along side NextJS V13/React V18 etc.

And now getting the following error:

error - ReferenceError: window is not defined
    at /private/tmp/react-flickity-component-example/node_modules/react-flickity-component/dist/react-flickity-component.umd.js:2:47057
    at /private/tmp/react-flickity-component-example/node_modules/react-flickity-component/dist/react-flickity-component.umd.js:2:47088
    at /private/tmp/react-flickity-component-example/node_modules/react-flickity-component/dist/react-flickity-component.umd.js:1:75
    at Object.<anonymous> (/private/tmp/react-flickity-component-example/node_modules/react-flickity-component/dist/react-flickity-component.umd.js:1:279)
....

I found other issues #4 (comment) that attempt to solve this issue using the following:

const Flickity =
  typeof window !== "undefined"
    ? require("react-flickity-component")
    : () => null

However prior to upgrading to V4 we hadn't had this issue.

I've created a clean instance of the react-flickity-component-example, bringing it up to speed with the latest versions and was able to replicate the issue. See the window-error-demo branch.

Any idea how we can overcome this issue whilst keeping this component in SSR for performance reasons?

@yaodingyd
Copy link
Owner

Are you sure this branch has your change? the latest commit is still on 11/16/2020.

@alexw23
Copy link
Author

alexw23 commented Jan 30, 2023

Code is up now, there was an error pushing which I didn't realise.

@yaodingyd
Copy link
Owner

can you try v4.0.1?

@alexw23
Copy link
Author

alexw23 commented Feb 1, 2023

That's working now, thanks for the fix!

@alexw23 alexw23 closed this as completed Feb 1, 2023
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