<Handle />
<Handle /> 组件用于你的 自定义节点 中定义连接点。
¥The <Handle /> component is used in your custom nodes
to define connection points.
import { Handle, Position } from '@xyflow/react';
export const CustomNode = ({ data }) => {
return (
<>
<div style={{ padding: '10px 20px' }}>
{data.label}
</div>
<Handle type="target" position={Position.Left} />
<Handle type="source" position={Position.Right} />
</>
);
};属性
¥Props
对于 TypeScript 用户,<Handle /> 组件的 props 类型导出为 HandleProps。
¥For TypeScript users, the props type for the <Handle /> component is exported
as HandleProps.
| Name | Type | Default |
|---|---|---|
id | string | nullId of the handle. | |
type | 'source' | 'target'Type of the handle. | "source" |
position | PositionThe position of the handle relative to the node. In a horizontal flow source handles are
typically | Position.Top |
isConnectable | booleanShould you be able to connect to/from this handle. | true |
isConnectableStart | booleanDictates whether a connection can start from this handle. | true |
isConnectableEnd | booleanDictates whether a connection can end on this handle. | true |
isValidConnection | IsValidConnectionCalled when a connection is dragged to this handle. You can use this callback to perform some
custom validation logic based on the connection target and source, for example. Where possible,
we recommend you move this logic to the | |
onConnect | OnConnectCallback called when connection is made | |
...props | Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "id"> |