MCPcopy Create free account
hub / github.com/adobe/react-spectrum / update

Function update

packages/react-stately/src/data/useTreeData.ts:461–481  ·  view source on GitHub ↗
(oldKey: Key, newValue: T)

Source from the content-addressed store, hash-verified

459 });
460 },
461 update(oldKey: Key, newValue: T) {
462 setItems(({items, nodeMap: originalMap}) =>
463 updateTree(
464 items,
465 oldKey,
466 oldNode => {
467 let node: TreeNode<T> = {
468 key: oldNode.key,
469 parentKey: oldNode.parentKey,
470 value: newValue,
471 children: null
472 };
473
474 let tree = buildTree(getChildren(newValue), originalMap, node.key);
475 node.children = tree.items;
476 return node;
477 },
478 originalMap
479 )
480 );
481 }
482 };
483}
484

Callers 1

updateTreeFunction · 0.70

Calls 4

setItemsFunction · 0.85
updateTreeFunction · 0.85
buildTreeFunction · 0.85
getChildrenFunction · 0.85

Tested by

no test coverage detected