refactor(general): fit view in store to prevent flickering, rename onLoad => onPaneReady

This commit is contained in:
moklick
2021-12-09 07:24:45 +01:00
parent 3a52efbb1f
commit 88582a86cc
17 changed files with 96 additions and 100 deletions
+3 -3
View File
@@ -5,7 +5,7 @@ import ReactFlow, {
addEdge,
applyNodeChanges,
applyEdgeChanges,
OnLoadParams,
ReactFlowInstance,
Connection,
Edge,
Node,
@@ -53,7 +53,7 @@ const initialNodes: Node[] = [
const initialEdges = [{ id: 'e1-2', source: '1', target: '2', label: 'This is a draggable edge' }];
const onLoad = (reactFlowInstance: OnLoadParams) => reactFlowInstance.fitView();
const onPaneReady = (reactFlowInstance: ReactFlowInstance) => reactFlowInstance.fitView();
const onEdgeUpdateStart = (_: React.MouseEvent, edge: Edge) => console.log('start update', edge);
const onEdgeUpdateEnd = (_: MouseEvent, edge: Edge) => console.log('end update', edge);
@@ -79,7 +79,7 @@ const UpdatableEdge = () => {
edges={edges}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onLoad={onLoad}
onPaneReady={onPaneReady}
snapToGrid={true}
onEdgeUpdate={onEdgeUpdate}
onConnect={onConnect}