Merge pull request #5154 from ibagov/onnodeschange-docstring-update

Fixed onNodesChange docstring in component-props.ts
This commit is contained in:
Moritz Klack
2025-04-07 11:25:22 +02:00
committed by GitHub
2 changed files with 8 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
'@xyflow/react': patch
---
Improve `onNodesChange` docs

View File

@@ -156,14 +156,14 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
* It is called on node drag, select, and move.
* @example // Use NodesState hook to create edges and get onNodesChange handler
* import ReactFlow, { useNodesState } from '@xyflow/react';
* const [edges, setNodes, onNodesChange] = useNodesState(initialNodes);
* const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
*
* return (<ReactFlow onNodeChange={onNodeChange} {...rest} />)
* @example // Use helper function to update edge
* @example // Use helper function to update node
* import ReactFlow, { applyNodeChanges } from '@xyflow/react';
*
* const onNodeChange = useCallback(
* (changes) => setNode((eds) => applyNodeChanges(changes, eds)),
* (changes) => setNode((nds) => applyNodeChanges(changes, nds)),
* [],
* );
*