refactor(react): pass fitView for ssr

This commit is contained in:
moklick
2023-10-23 16:01:22 +02:00
parent f2b36f2d33
commit 52a47a7a26
5 changed files with 20 additions and 5 deletions
+4 -2
View File
@@ -15,17 +15,19 @@ const getInitialState = ({
edges = [],
width,
height,
fitView,
}: {
nodes?: Node[];
edges?: Edge[];
width?: number;
height?: number;
fitView?: boolean;
} = {}): ReactFlowStore => {
const nextNodes = updateNodes(nodes, [], { nodeOrigin: [0, 0], elevateNodesOnSelect: false });
let transform: Transform = [0, 0, 1];
if (width && height) {
if (fitView && width && height) {
const nodesWithDimensions = nextNodes.map((node) => ({
...node,
width: node.size?.width,
@@ -89,7 +91,7 @@ const getInitialState = ({
autoPanOnConnect: true,
autoPanOnNodeDrag: true,
connectionRadius: 20,
onError: devWarn,
onError: () => null,
isValidConnection: undefined,
lib: 'react',