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 #12

Open
bigchamp opened this issue Sep 8, 2020 · 4 comments
Open

Window is not defined #12

bigchamp opened this issue Sep 8, 2020 · 4 comments

Comments

@bigchamp
Copy link

bigchamp commented Sep 8, 2020

After installation i tried to launch my project locally, but got error window is not defined

@ltparis2018
Copy link
Contributor

Hm, that is unfortunately very little information - too little to be able to investigate the problem. Can you possibly give more information? E.g. How exactly do you integrate add-to-homescreen-react in your project? Can you provide the corresponding code snippet? Which module packer tool do you use? ...

BTW: You can find examples for integration and usage of the component within examples folder of the add-to-homescreen-react project. See https://github.com/as-ideas/add-to-homescreen-react#examples for details how to build and start them locally on your machine. Maybe these examples can help you with the integration of add-to-homescreen-react.

@mkontsek
Copy link

Most likely it's because of SSR, where window is not available.

@ltparis2018
Copy link
Contributor

That's right. Currently, this React component is not designed for SSR. I guess rendering it server-side doesn't make much sense either. For example, it needs information about the current platform (i.e. iOS, Android) it is running on, and also uses the local storage of the browser.

@acarnwath
Copy link

I had this issue as well on a Gatsby.js implementation. Using the loadable-components package ensured that it would only load on the client-side (and not break on SSR compilation).

import loadable from "@loadable/component";
const AddToHomeScreen = loadable(() => import('@ideasio/add-to-homescreen-react')

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

4 participants