Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

getPropsReducer(tree: PropertyTree): MyComponentProps - A reducer function that reads from the components PropertyTree and returns the shape of the props property of a component's React props (i.e. this.props.props  instance of MyComponentProps). For example, a component's meta should now look something like this.

Editor_notes

The examples on the rest of the page look like Kotlin. Is that correct? Not certain if that's worth stating for module/component authors.  - Paul S. 

(Not Kotlin, but Typescript - YN)

Code Block
languagejava
export class MyComponentMeta implements ComponentMeta {
    // Renamed from getViewClass. Returns a PComponent 
    // which is either a class or functional Perspective component.
    getViewComponent(): PComponent {
        return Label;

    // Reducer function whose return value gets mapped to 
    // 'this.props.props' for class components or 'props.props'
    // for functional components
    getPropsReducer(tree: PropertyTree): MyComponentProps {
        return {
            value: tree.readString("value"),
        };
    }    

    getComponentType(): string {
        return ID;
    }    

    getDefaultSize(): SizeObject {
        return { width: 50, height: 50 };
    }
}

...