Skip to Content
React Flow 13 is here! Read the announcement →
ReferenceHooks

useInternalNodes()

Source on GitHub 

This hook returns an array of internal node objects for the passed node IDs. Components that use this hook will re-render whenever any of the selected nodes change.

import { useInternalNodes } from '@xyflow/react'; export default function () { const internalNodes = useInternalNodes(['node-1', 'node-2']); const absolutePosition = internalNodes[0].internals.positionAbsolute; return ( <div> The absolute position of node-1 is at: <p>x: {absolutePosition.x}</p> <p>y: {absolutePosition.y}</p> </div> ); }

Signature

Parameters:
NameTypeDefault
idsreadonly string[]

An array of node IDs to observe. An empty array returns no nodes.

Returns:

TypeScript

This hook accepts a generic type argument of custom node types. See this section in our TypeScript guide for more information.

const internalNodes = useInternalNodes<CustomNodeType>(['node-1', 'node-2']);