const daughter={name:'Kisha'}
const son={name:'Gideon'}
const daughter={name:'Alex'}
const mother={
name:'Asheleigh',
children:[son, daughter]
}
class Tree{
constructor(value)
{
this.value=value;
this.children=[];
}
insertChild(value){
const newTree=new Tree(value)
this.children.push(newTree);
return newTree
}
}
const myTree=new Tree(1);
console.log(myTree)
/*
{
value:1,
children:[]
}
*/
this.state={
data:{}
nodes:[]
}
I receive the selected plugin (node in this example) as props. The selected node is of the type feed item. Matan converts it into a plugin instance.
this.setState({
nodes:transformedNodes,
data:{
...prevState.data,
parent
})
The 1st screen has a dropdown which allows the user to select the parent from the tree. I pass down a handleSelect function as a prop to the 1st screen so that the transformedNodes can be displayed as a dropdown and the selected parent node can bubble up and I can change the selected plugin in the parent component.