Guides -> Custom Nodes -> Using Multiple Handles
parent
4b962e81d6
commit
89b66be215
36
src/App.tsx
36
src/App.tsx
|
@ -1,16 +1,17 @@
|
||||||
import { useState, useCallback } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import ReactFlow, {
|
import ReactFlow, {
|
||||||
Background,
|
addEdge,
|
||||||
Controls,
|
|
||||||
applyEdgeChanges,
|
applyEdgeChanges,
|
||||||
applyNodeChanges,
|
applyNodeChanges,
|
||||||
addEdge,
|
Background,
|
||||||
Node,
|
|
||||||
Edge,
|
|
||||||
NodeChange,
|
|
||||||
EdgeChange,
|
|
||||||
Connection,
|
Connection,
|
||||||
|
Controls,
|
||||||
|
Edge,
|
||||||
|
EdgeChange,
|
||||||
|
Node,
|
||||||
|
NodeChange,
|
||||||
NodeTypes,
|
NodeTypes,
|
||||||
|
Position,
|
||||||
} from 'reactflow';
|
} from 'reactflow';
|
||||||
|
|
||||||
import TextUpdaterNode from './components/TextUpdaterNode';
|
import TextUpdaterNode from './components/TextUpdaterNode';
|
||||||
|
@ -22,7 +23,10 @@ const rfStyle = {
|
||||||
backgroundColor: '#B8CEFF',
|
backgroundColor: '#B8CEFF',
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialEdges: Edge[] = [];
|
const initialEdges: Edge[] = [
|
||||||
|
{ id: 'edge-1', source: 'node-1', target: 'node-2', sourceHandle: 'a' },
|
||||||
|
{ id: 'edge-2', source: 'node-1', target: 'node-3', sourceHandle: 'b' },
|
||||||
|
];
|
||||||
|
|
||||||
const initialNodes: Node[] = [
|
const initialNodes: Node[] = [
|
||||||
{
|
{
|
||||||
|
@ -31,6 +35,20 @@ const initialNodes: Node[] = [
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: { value: 123 },
|
data: { value: 123 },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'node-2',
|
||||||
|
type: 'output',
|
||||||
|
targetPosition: Position.Top,
|
||||||
|
position: { x: 0, y: 200 },
|
||||||
|
data: { label: 'node 2' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'node-3',
|
||||||
|
type: 'output',
|
||||||
|
targetPosition: Position.Top,
|
||||||
|
position: { x: 200, y: 200 },
|
||||||
|
data: { label: 'node 3' },
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const nodeTypes: NodeTypes = { textUpdater: TextUpdaterNode };
|
const nodeTypes: NodeTypes = { textUpdater: TextUpdaterNode };
|
||||||
|
|
Loading…
Reference in New Issue