isNode()
Source on GitHub (opens in a new tab)
Test whether an object is useable as an 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)) {
// ..
}
Signature
Name | Type |
---|---|
#Params |
|
# item | any |
#Returns |
|
boolean Tests if whatever you passed in can be used as an node. If
you're using TypeScript, this function actions as a type guard and will
narrow the type of whatever you pass in to an Node if it returns true. |