Skip to content

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

fix: simplify key check for rendering nodes in CustomNode component

AykutSaracd153015d3089
diff --git a/apps/www/src/features/editor/views/GraphView/CustomNode/index.tsx b/apps/www/src/features/editor/views/GraphView/CustomNode/index.tsx
index 6358ffe4..ed015b20 100644
--- a/apps/www/src/features/editor/views/GraphView/CustomNode/index.tsx
+++ b/apps/www/src/features/editor/views/GraphView/CustomNode/index.tsx
@@ -47,8 +47,8 @@ const CustomNodeWrapper = (nodeProps: NodeProps<NodeData>) => {
}}
>
{({ node, x, y }) => {
- const hasKey = nodeProps.properties.text[0].key;
- if (!hasKey) return <TextNode node={nodeProps.properties as NodeData} x={x} y={y} />;
+ if (nodeProps.properties.text[0].key == null)
+ return <TextNode node={nodeProps.properties as NodeData} x={x} y={y} />;
return <ObjectNode node={node as NodeData} x={x} y={y} />;
}}
diff --git a/packages/jsoncrack-react/src/components/CustomNode.tsx b/packages/jsoncrack-react/src/components/CustomNode.tsx
index 02965bdc..c4f8c9e1 100644
--- a/packages/jsoncrack-react/src/components/CustomNode.tsx
+++ b/packages/jsoncrack-react/src/components/CustomNode.tsx
@@ -36,8 +36,7 @@ const CustomNodeBase = ({ onNodeClick, ...nodeProps }: CustomNodeProps) => {
}}
>
{({ node, x, y }) => {
- const hasKey = nodeProps.properties.text[0]?.key;
- if (!hasKey) {
+ if (nodeProps.properties.text[0]?.key == null) {
return <TextNode node={nodeProps.properties as NodeData} x={x} y={y} />;
}