Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

improve types

AykutSarac897ceabfe0bd
diff --git a/src/components/CustomNode/index.tsx b/src/components/CustomNode/index.tsx
index dad32de2..1be41ab5 100644
--- a/src/components/CustomNode/index.tsx
+++ b/src/components/CustomNode/index.tsx
@@ -24,7 +24,7 @@ export const CustomNode = (nodeProps: NodeProps) => {
return (
<Node {...nodeProps} label={<Label style={baseLabelStyle} />}>
{({ width, height, x, y, node }) => {
- if (properties.text instanceof Object) {
+ if (Array.isArray(properties.text)) {
return (
<ObjectNode
value={properties.text}
@@ -38,7 +38,7 @@ export const CustomNode = (nodeProps: NodeProps) => {
return (
<TextNode
- node={node}
+ node={node as NodeData}
isParent={properties.data.isParent}
value={properties.text}
width={width}
diff --git a/src/types.d.ts b/src/types.d.ts
index 6be86b33..f254c275 100644
--- a/src/types.d.ts
+++ b/src/types.d.ts
@@ -1,4 +1,10 @@
-type CanvasDirection = "LEFT" | "RIGHT" | "DOWN" | "UP"
+type CanvasDirection = "LEFT" | "RIGHT" | "DOWN" | "UP";
+
+interface CustomNodeData {
+ isParent: true;
+ hasChild: !!children.length;
+ children;
+}
interface NodeData<T = any> {
id: string;