From 6dcb9f51204919dc890414271a085cdb7fde4c09 Mon Sep 17 00:00:00 2001 From: moklick Date: Mon, 11 May 2020 18:50:09 +0200 Subject: [PATCH] refactor(renderer): show error when no width or height is set #196 --- src/container/GraphView/index.tsx | 5 +++++ src/container/ReactFlow/index.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/container/GraphView/index.tsx b/src/container/GraphView/index.tsx index aa78cef8..3423c334 100644 --- a/src/container/GraphView/index.tsx +++ b/src/container/GraphView/index.tsx @@ -89,6 +89,11 @@ const GraphView = memo( } const size = getDimensions(rendererNode.current); + + if (size.height === 0 || size.width === 0) { + throw new Error('The React Flow parent container needs a width and a height to render the graph.'); + } + updateSize(size); }; diff --git a/src/container/ReactFlow/index.tsx b/src/container/ReactFlow/index.tsx index d7c86841..371a0deb 100644 --- a/src/container/ReactFlow/index.tsx +++ b/src/container/ReactFlow/index.tsx @@ -49,7 +49,7 @@ export interface ReactFlowProps extends Omit, 'on const ReactFlow = ({ style, onElementClick, - elements, + elements = [], children, nodeTypes, edgeTypes,