Great discussion of a topic (trees) that never seems to get enough attention.

Great discussion of a topic (trees) that never seems to get enough attention. Just one point — in your initial example of a Tree class React component, you return a <ul> as the root element.

As a tree component expands in functionality, it might be more intuitive if the recursive tree class (e.g. perhaps a “TreeItem”) returned an <li>, with a child <ul> and map therein if there are children. Otherwise handling a expand/collapse of a child item to the parent gets a little strange, among other things.

In other words, all trees start with a root node, not a list of root nodes — just like in nature.

Thanks again!

Leave a Reply

Your email address will not be published. Required fields are marked *