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

ReferenceError: document is not defined #84

Open
cdnbelgium opened this issue Sep 28, 2021 · 2 comments
Open

ReferenceError: document is not defined #84

cdnbelgium opened this issue Sep 28, 2021 · 2 comments

Comments

@cdnbelgium
Copy link

cdnbelgium commented Sep 28, 2021

Love how you have come up with this solution to the problem of adding to home screen with IOS devices. I guess Apple really does not like the PWA as they could potentially be taking away that cash cow of revenue from their app store. But I am having a slight issue with it. Go easy on me. Newbee ;)

I am using this in a Next project.

npm i react-ios-pwa-prompt

then

import PWAPrompt from 'react-ios-pwa-prompt'

then put it in with my index,js code

     '<PWAPrompt />'

the '' are only there to show what I had coded...it would not show up in query otherwise.
getting this in response:

Server Error
ReferenceError: document is not defined

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
s
file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:2222)
v
file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:3463)
l
file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:2161)
e.exports
file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:3795)
Object.
file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:1410)
r
file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:432)
Module.
file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:12225)
r
file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:432)

file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:1237)

file:///C:/Users/jscha/Desktop/swim/node_modules/react-ios-pwa-prompt/dist/react-ios-pwa-prompt.js (1:1246)

Any advice?

Cheers Joel

@jpalo
Copy link

jpalo commented Oct 5, 2021

Try loading this component using loadable-components https://github.com/gregberge/loadable-components to overcome the SSR issue you're probably experiencing.

import loadable from '@loadable/component'
const PWAPrompt = loadable(() => import("react-ios-pwa-prompt"))

@chidera-ugo
Copy link

Import it dynamically and disable SSR

const PWAPrompt = dynamic(() => import('react-ios-pwa-prompt'), { ssr: false, });

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

3 participants