參考工具

isEdge()

GitHub 上的原始碼

測試物件是否可用作 Edge。在 TypeScript 中,這是一個類型保護,如果返回 true,它會將您傳入的任何內容的類型縮小為 Edge

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

簽名

#參數
#item
any
#返回值
boolean
測試您傳入的任何內容是否可用作邊緣。如果您正在使用 TypeScript,此函數會作為類型保護,並且如果返回 true,則會將您傳入的任何內容的類型縮小為 Edge。