add types

This commit is contained in:
AykutSarac 2022-04-30 17:49:40 +03:00
parent fc6a0e9c79
commit f54337b04d
2 changed files with 10 additions and 4 deletions

View File

@ -1,12 +1,12 @@
import React from "react";
import { Canvas } from "reaflow";
import { Canvas, EdgeData, NodeData } from "reaflow";
import { CustomNode } from "src/components/CustomNode";
import { useConfig } from "src/hocs/config";
import { getEdgeNodes } from "src/containers/LiveEditor/helpers";
export const Graph = () => {
const [nodes, setNodes] = React.useState([]);
const [edges, setEdges] = React.useState([]);
const [nodes, setNodes] = React.useState<NodeData[]>([]);
const [edges, setEdges] = React.useState<EdgeData[]>([]);
const [size, setSize] = React.useState({
width: 2000,
height: 2000,

View File

@ -14,7 +14,13 @@ const toString = (value: string | object) => {
return String(value);
};
export function getEdgeNodes(graph: any, isExpanded: boolean = true): any {
export function getEdgeNodes(
graph: string,
isExpanded: boolean = true
): {
nodes: NodeData[];
edges: EdgeData[];
} {
graph = JSON.parse(graph);
const elements = parser(graph);