Skip to Content

isEdge()

GitHub 上的源代码

¥Source on GitHub

测试一个对象是否可以用作 Edge。在 TypeScript 中,这是一个类型保护,如果返回 true,它将缩小你传递给 Edge 的任何内容的类型。

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

import { isEdge } from '@xyflow/react'; const edge = { id: 'edge-a', source: 'a', target: 'b', }; if (isEdge(edge)) { // ... }

签名

¥Signature

Parameters:
NameTypeDefault
elementunknown

The element to test

Returns:
boolean

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

Last updated on