Functions
moveItemOnTree

moveItemOnTree Function

moveItemOnTree function allows for repositioning an item within the tree data structure, ensuring the tree maintains its integrity after the move.

OptionTypeDescription
treeTreeDataThe current tree data structure.
fromTreeSourcePositionThe source position of the item being moved, including its parent ID and index.
toTreeDestinationPositionThe destination position for the item, including the target parent ID and new index.
returnsTreeDataThe updated tree data structure after the item has been moved.

Example Usage

const updatedTree = moveItemOnTree(treeData, { parentId: 'root', index: 0 }, { parentId: 'root', index: 2 });