Comments (2)
This solution seems to work for build: gatsbyjs/gatsby#13219 (comment) . Have you tried it?
from react-paperjs.
Thanks so much for the help here. This solves the jsdom issue. You also need @loadable/component to prevent build/ssr issues too.
Interestingly because we need named imports I couldn't use @loadable/component easily for the multiple named imports needed with this project (unless there's a trick i'm missing) so I made a component with react-paperjs normally then imported that component with @loadable/component. If there is a way to use @loadable/component or similar deferred loader directly with multiple named imports let me know.
Hope this helps someone else and thanks for the response....
For GatsbyJS - Create a component exactly like the documentation in this repo, add the code to gatsby-node.js as above, code below:
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html") {
actions.setWebpackConfig({
module: { rules: [{ test: /node_modules\/paper/, use: loaders.null() }] },
});
}
};
Import your react-paperjs component with @loadable/component as below:
const PaperComponent = loadable(
async () => (await import("../components/Paper")).PaperComponent,
{
fallback: <>Loading...</>,
}
);
You can then use it normally in things like Gatsby and Next with SSR.
I chose a named export/import for my react-paperjs component, but if its a default export the import is simpler, docs here: https://loadable-components.com/
@psychobolt if the above all sounds like reasonable instructions and info I hope its useful.
I made a simple gatsby starter site with the above code here:
https://github.com/amcc/gatsby-paper-fiber
from react-paperjs.
Related Issues (20)
- Can I smooth a path? HOT 3
- Touch events HOT 1
- TypeError: mergeProps is not a function HOT 12
- CompoundPath HOT 3
- Error Can't resolve dependency HOT 4
- Example for mouse events HOT 2
- How do you use Paper.onFrame for animation? HOT 2
- Support for React 17 HOT 1
- Loading SVGs HOT 2
- Prop changes don't trigger component redraws HOT 6
- TypeError: Cannot read property 'alternate' of undefined [issue in react 17.0.2] HOT 2
- Error in function getNearestMountedFiber HOT 2
- Extending PaperTypes HOT 1
- Issue in extending PaperRenderer HOT 3
- Does it work with react 18?
- Issue with Paper.js Polygon Tool in Mirador-Annotation Library
- How to use Path.Arc? HOT 1
- Update react-paperjs-editor version
- Detected multiple renderers rendering the same context provider HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-paperjs.