useNodesData()
Source on GitHub (opens in a new tab)
This hook lets you subscribe to changes of a specific nodes data
object.
import { useNodesData } from '@xyflow/react';
export default function () {
const nodeData = useNodesData('nodeId-1');
const nodesData = useNodesData(['nodeId-1', 'nodeId-2']);
}
Signature
Name | Type |
---|---|
#Params |
|
# nodeIds | string | string[] A single node ID or an array of node IDs whose `data` objects you want to observe |
#Returns |
|
# id | string |
# type | string |
# data | any | any[] |
Typescript
This hook accepts a generic type argument of custom node types. See this section in our Typescript guide for more information.
const nodesData = useNodesData<NodesType>(['nodeId-1', 'nodeId-2']);