imagine I have this state
const state = [
{text: 'node1'},
{text: 'node2', children: [
{text: 'subNode1'},
{text: 'subNode2', children: [
{text: 'node1'}]
}]
}]
So as a requirement, this tree structure can go nested arbitrarily. I want to be able to address the array item {text: 'node1'}
; the nested one inside node2->subNode2 such that I can edit it and also find that it is a duplicate (has same text) to the one with index 0 in the state array.
Can you help me with that? I need to have a reducer that can mutate the state to reflect this issue given that the nesting can go arbitrarily deeper.
Many Thanks! Muchtar