Updating Expanded Items
The TreeView provides specific approaches for working with its data and updating the
The available options are:
The following example demonstrates how to directly update the TreeView items.
processTreeViewItems helper function updates the items in an immutable way, that is, works with a copy of the data. While using
processTreeViewItems is similar to creating a copy of the data before each item update, the
data field of the application state does not change. That is why, the helper function approach is useful when other components depend on the
The following example demonstrates how to introduce an additional state field (
expand) which holds the IDs of the expanded items and is passed to
processTreeViewItems on each re-render.