mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-20 05:12:54 +08:00
add types
This commit is contained in:
parent
fc6a0e9c79
commit
f54337b04d
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user