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

Window is not defined in SSR #5

Open
gregorskii opened this issue Sep 30, 2019 · 1 comment
Open

Window is not defined in SSR #5

gregorskii opened this issue Sep 30, 2019 · 1 comment

Comments

@gregorskii
Copy link

Error: window is not defined when using SSR such as nextjs.

@sitoftonic
Copy link

@gregorskii I also faced the same problem. Tried to import the module dynamically with ssr to false:

const { Experiment, Variant } = dynamic(() => import('react-google-optimize'), { ssr: false });

But then the NextJs application throws the following Server Error:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

I have investigated the bundled code and it seems the export is named:

export { Experiment, Variant };

Does anybody know how to solve this?

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