isNode() - React Flow

Test whether an object is usable as a Node. In TypeScript this is a type guard that will narrow the type of whatever you pass in to Node if it returns true.

import { isNode } from '@xyflow/react';
 
const node = {
  id: 'node-a',
  data: {
    label: 'node',
  },
  position: {
    x: 0,
    y: 0,
  },
};
 
if (isNode(node)) {
  // ..
}
NameTypeDefaultelementunknown

The element to test.

boolean

Tests whether the provided value can be used as a Node. If you’re using TypeScript, this function acts as a type guard and will narrow the type of the value to Node if it returns true.