Perspective - Using PropertyTree.write()

Hello,

I would like to understand the PropertyTree.write() and how to use it.

I have my Component Props:

interface SchedulerProps {
    events: Array<Object>;
    writeEventData: Array<Object>;
}

And my reducer function:

getPropsReducer(tree: PropertyTree): SchedulerProps {
        return {      
            events: tree.readArray("events", []),
            writeEventData: (newEvents) => tree.write("events", newEvents)
        };
    }

And I call this in my code:

onEventEdit(updateProps) {
        // where updateProps is an array of objects to be written to the events node/prop
        this.props.props.writeEventData(updateProps);
    }

My questions:

  • Is this the correct way to write new data to a prop?
  • Could you give some examples of how to write tree.write()? Am I using the arrow function correctly in my reducer?
  • What kinds of data types can be passed to tree.write()? Passing an array is causing errors.
  • Is this.props.props.writeEventData(updateProps) the correct way to call it? I get an error saying this is not callable

Any help appreciated!

Thanks,
Kirsty