Skip to content

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

add conditional rendering component

AykutSaraca772d7206d92
diff --git a/src/components/CustomNode/index.tsx b/src/components/CustomNode/index.tsx
index 15d504a9..3936aacb 100644
--- a/src/components/CustomNode/index.tsx
+++ b/src/components/CustomNode/index.tsx
@@ -1,4 +1,5 @@
import React from "react";
+import RenderIfVisible from "react-render-if-visible";
import { Label, Node, NodeProps } from "reaflow";
import ObjectNode from "./ObjectNode";
import TextNode from "./TextNode";
@@ -18,6 +19,12 @@ const baseLabelStyle = {
strokeWidth: 0,
};
+export const ConditionalWrapper: React.FC<{
+ condition?: boolean;
+ children: React.ReactNode;
+}> = ({ condition, children }) =>
+ condition ? <RenderIfVisible>{children}</RenderIfVisible> : <>{children}</>;
+
export const CustomNode = (nodeProps: NodeProps) => {
const { properties } = nodeProps;