So I have the following state:
[
{
name: "Main Tree",
branches: [
{
name: "Branch 1",
branches: []
},
{
name: "Branch 2",
branches: [
{
name: "Sub Branch 1",
branches: []
}
]
}
]
}
]
My question is, how do I append another branch under the branches in Sub Branch 1 using state operators? I tried the solution on this link (State Operators) but it converts the data from array into object which is not the desired output.
Also the above scenario is just an example, my use-case is that it could be an infinite level of sub branches with branches inside them.
Thank you in advance.