Add comments

This commit is contained in:
peterkogo
2025-03-05 15:16:12 +01:00
parent f208223400
commit c98b6c01f9
+5
View File
@@ -280,9 +280,14 @@ export function useReactFlow<NodeType extends Node = Node, EdgeType extends Edge
?.values() ?? []
),
fitView: async (options: FitViewOptions<NodeType> | undefined) => {
// We either create a new Promise or reuse the existing one
// Even if fitView is called multiple times in a row, we only end up with a single Promise
const fitViewResolver = store.getState().fitViewResolver ?? Promise.withResolvers<boolean>();
// We schedule a fitView by setting fitViewQueued and triggering a setNodes
store.setState({ fitViewQueued: true, fitViewOptions: options, fitViewResolver });
batchContext.nodeQueue.push((nodes) => [...nodes]);
return fitViewResolver.promise;
},
};