I am using Antd Tree to render the tree view of the data, at the beginning the data of the tree is a flat array of objects with each object having a key parentId
indicating the parent of that node.
I am then using a function to convert this flat array into hierarchical structure to pass it to the Tree
component of the antd
library
Please refer this Codesandbox link to see the project code
the flat array is in the data.json file in the src
folder
I have done this because pasting the entire code of the project would look clumsy. There is a textbox to enter the new nodes name after selecting an existing node in the tree as the parent of the new node, there are no errors and in the render
method in the console the updated state is also getting logged correctly but the tree is not getting rendered reflecting the updated data, I am using shouldComponentUpdate
method thinking it would update the DOM
if anyone could resolve the problem then it will be a great help
THANK YOU