Skip to content

Commit

Permalink
refactor(renderer): show error when no width or height is set #196
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed May 11, 2020
1 parent 7a2bff2 commit 6dcb9f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/container/GraphView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
2 changes: 1 addition & 1 deletion src/container/ReactFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ReactFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
const ReactFlow = ({
style,
onElementClick,
elements,
elements = [],
children,
nodeTypes,
edgeTypes,
Expand Down

0 comments on commit 6dcb9f5

Please sign in to comment.