Fix all typescript type issues
parent
f06509e904
commit
8d70c86460
18
src/App.tsx
18
src/App.tsx
|
@ -5,14 +5,19 @@ import ReactFlow, {
|
|||
applyEdgeChanges,
|
||||
applyNodeChanges,
|
||||
addEdge,
|
||||
Node,
|
||||
Edge,
|
||||
NodeChange,
|
||||
EdgeChange,
|
||||
Connection,
|
||||
} from 'reactflow';
|
||||
|
||||
// we have to import the React Flow styles for it to work
|
||||
import 'reactflow/dist/style.css';
|
||||
|
||||
const initialEdges = [];
|
||||
const initialEdges: Edge[] = [];
|
||||
|
||||
const initialNodes = [
|
||||
const initialNodes: Node[] = [
|
||||
{
|
||||
id: '1',
|
||||
data: { label: 'Hello' },
|
||||
|
@ -31,16 +36,19 @@ const Flow = () => {
|
|||
const [edges, setEdges] = useState(initialEdges);
|
||||
|
||||
const onNodesChange = useCallback(
|
||||
changes => setNodes(nds => applyNodeChanges(changes, nds)),
|
||||
(changes: NodeChange[]) =>
|
||||
setNodes((nds: Node[]) => applyNodeChanges(changes, nds)),
|
||||
[],
|
||||
);
|
||||
const onEdgesChange = useCallback(
|
||||
changes => setEdges(eds => applyEdgeChanges(changes, eds)),
|
||||
(changes: EdgeChange[]) =>
|
||||
setEdges((eds: Edge[]) => applyEdgeChanges(changes, eds)),
|
||||
[],
|
||||
);
|
||||
|
||||
const onConnect = useCallback(
|
||||
params => setEdges(eds => addEdge(params, eds)),
|
||||
(params: Edge | Connection) =>
|
||||
setEdges((eds: Edge[]) => addEdge(params, eds)),
|
||||
[],
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue