Perspective - Using PropertyTree.write()


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

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!