isNode()
测试一个对象是否可以用作 Node。在 TypeScript 中,这是一个类型保护,如果返回 true,它将缩小你传递给 Node 的任何内容的类型。
¥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)) {
// ..
}签名
¥Signature
Parameters:| Name | Type | Default |
|---|---|---|
element | unknownThe element to test. |
Last updated on