Skip to Content
You are viewing the v12 docs of React Flow. You can find the latest version here.
ReferenceHooks

useNodesData()

Source on GitHub 

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

Parameters:
NameTypeDefault
nodeIdstring

The id of the node to get the data from.

Returns:
DistributivePick<NodeType, "id" | "type" | "data"> | null

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']);
Last updated on