Comments (3)
MyCustomStencilComponent is just alias for a constant string variable that you define in your renderer. For example, in the reference above I could use TYPE_NAME in the App component.
import MyCustomStencil from './MyCustomStencil';
const TYPE_NAME = 'myStencil';
class MyPaperRenderer extends PaperRenderer {
getInstanceFactory() {
return {
...this.defaultTypes, /*
refer to default types
see https://github.com/psychobolt/react-paperjs/blob/master/src/Paper.types.js#L42
*/
[TYPE_NAME]: (props, paper) => new MyCustomStencil(props),
};
}
}
const App = (props) => (
<PaperContainer renderer={MyPaperRenderer}>
<TYPE_NAME />
</PaperContainer>
);
You can look at the reference, and see there is a link to default types.
Below is additional info, not pertaining to your original question but helpful to the docs.
There is no specific structure for the class MyCustomStencil
, but its expected you composite it so it extends Paper's prototypes such as from Item or Group
. Then the raster is instantiated and have proper methods to append to the tree for during react-paperjs
' reconciler's lifecycle. (see host config). However, if you need further advanced customization, lucky enough you already have access to extend the renderer's host config.
from react-paperjs.
Oh, Thanks a lot @psychobolt , I was close and now issue resolved
Successfully extended.
from react-paperjs.
@im-hamza-dev No problem, I just merged a related PR. There is a new version (1.0.3) out now with these changes.
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
- SSR and GatsbyJS and jsdom HOT 2
- Error in function getNearestMountedFiber HOT 2
- Extending PaperTypes HOT 1
- 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.