Closed graeme120 closed 1 year ago
Sounds like a bug in hoist-non-react-statics.
However, I would consider removing this dependency as it's lagging a little behind everchanging requirements.
Sounds like a bug in hoist-non-react-statics.
However, I would consider removing this dependency as it's lagging a little behind everchanging requirements.
@theKashey For sure, how do I remove the dependency? And would the plugin work without it? Would I have to substitute it with anything?
The change is required from within loadable.
However can you try debug the issue as there should be a reason why this functionality blows up, something very particular.
The change is required from within loadable.
However can you try debug the issue as there should be a reason why this functionality blows up, something very particular.
@theKashey Oh, as in someone would need to commit a change to the loadable repo? And yes, it seems to be the importing of react-p5-wrapper that blows it up, but I cannot see any reason why it would be interpreted as a simple string. Any workarounds you know of that do the same thing as loadable-components? I'm using Gatsby and having a very hard time getting my p5.js files to do SSR. Also quite new to react/node/gatsby
..... because you are expected to do import { ReactP5Wrapper } from "react-p5-wrapper";
- a named, not default export.
just change your code a little
import loadable from "@loadable/component"
const LoadableP5 = loadable(() => import('react-p5-wrapper'), {
resolveComponent: ({ReactP5Wrapper}) => ReactP5Wrapper,
});
see https://loadable-components.com/docs/api-loadable-component/#optionsresolvecomponent
..... because you are expected to do
import { ReactP5Wrapper } from "react-p5-wrapper";
- a named, not default export.just change your code a little
import loadable from "@loadable/component" const LoadableP5 = loadable(() => import('react-p5-wrapper'), { resolveComponent: ({ReactP5Wrapper}) => ReactP5Wrapper, });
see https://loadable-components.com/docs/api-loadable-component/#optionsresolvecomponent
@theKashey Hm, its loading now, but when I switch pages and return it doesnt reload, the sketch is just stuck as 'loading', does that have anything to do with loadable-components? Also, thank you so much for the advice!
Here are the errors in the console:
GET http://localhost:8000/about/[object%20Object] 404 (Not Found)
head-export-handler-for-browser.js:72 TypeError: o.indexOf is not a function at eval (p5.min.js:2:1)
Yeah, I am not sure loadable is a problem here, as well not sure it can be a solution - the new problem seems to be originated in P5.
🐛 Bug Report
Getting this issue every time I try to use loadable-components with react-p5-wrapper. The plugin works fine unless i'm trying to use loadable components, wherein i'm given this error message
Error in function hoistNonReactStatics in ./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js:70 Cannot convert undefined or null to object
./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js:70
68 | // don't hoist over string (html) components 69 | if (objectPrototype) { 70 | var inheritedComponent = getPrototypeOf(sourceComponent); 71 | 72 | if (inheritedComponent && inheritedComponent !== objectPrototype) { 73 | hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
To Reproduce