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

Running into an issue with Gatsby.js, "Window is not defined" #37

Closed
matt0rtega opened this issue Aug 12, 2019 · 4 comments
Closed

Running into an issue with Gatsby.js, "Window is not defined" #37

matt0rtega opened this issue Aug 12, 2019 · 4 comments

Comments

@matt0rtega
Copy link

Was wondering if anyone else was running into this problem with Gatsby.js. I am getting a "Window is not defined error" when trying to build with p5 and react-p5-wrapper. It seems like the "window" is actually in the p5.js file. I can currently run in on the local server, just can't build the Gatsby app.

@FreeArtBureau
Copy link

Hi there, I'm getting the same error and behaviour. I'm not too sure how to solve this issue as I'm new to the one page app business & components. Any solutions please?

@and-who
Copy link
Contributor

and-who commented Aug 21, 2019

Gatsby is a Framework which implements Serverside rendering and such.
I imagine that there is the Issue, since there is no window at compile-/render-time.

This is only a guess, since I never used Gatsby

I Will close this Issue, since this is related to:
#2
And a possible Solution could be:
#2 (comment)

@and-who and-who closed this as completed Aug 21, 2019
@willmcl
Copy link

willmcl commented Jan 20, 2021

@and-who is correct. This is the method that worked for me:

Install loadable: npm install @loadable/component

import sketch from 'path-to-sketch';
import loadable from '@loadable/component';
const LoadableP5 = loadable(() => import('react-p5-wrapper'));

function MyHolder() {
    return <LoadableP5 sketch={sketch} color="green"/>
}

export default MyHolder;

@graeme120
Copy link

@and-who is correct. This is the method that worked for me:

Install loadable: npm install @loadable/component

import sketch from 'path-to-sketch';
import loadable from '@loadable/component';
const LoadableP5 = loadable(() => import('react-p5-wrapper'));

function MyHolder() {
    return <LoadableP5 sketch={sketch} color="green"/>
}

export default MyHolder;

@willmcl I'm getting this error any time I try to use this method

Error in function hoistNonReactStatics in ./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js:70
"Don't hoist over string (html) components

Any ides what this could mean / why this is happening?

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

5 participants