r/learnreactjs • u/Honeydew-Jolly • Jul 28 '22
Question learning Data structures - trees w/ React
Hey folks, just checking if this is an appropriate subreddit to post about this, let me know where should I post it in case this is not the right place
I'm studying data structures with React, and I'm trying to build a tree and add new nodes to it.
I've been hitting my head against the wall with some details because recursion makes it confusing in some parts. I could post a link to a codesandbox here if someone can take a look and provide some advice.
what have I achieved so far: I managed to create a JSON that I use to render a tree with a recursive React component
what do I need help with: the problem is that I can't figure out how to add a new node, I have some code written, and it does update the tree data correctly, but the UI does not update for some reason
1
u/TacoDelMorte Jul 29 '22
Without seeing your code, this is difficult to help.
Are you updating the entire JSON data structure when the new node is added, or are you only updating the child node?
Are you using functional components or class components?
Are you utilizing useEffect at any point?
Definitely post your code.