Coder Social home page Coder Social logo

Comments (3)

psychobolt avatar psychobolt commented on September 8, 2024

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.

im-hamza-dev avatar im-hamza-dev commented on September 8, 2024

Oh, Thanks a lot @psychobolt , I was close and now issue resolved
Successfully extended.

from react-paperjs.

psychobolt avatar psychobolt commented on September 8, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.