chore(system): add polyfill for Promise.withResolvers #5210
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
isRectObject,
|
||||
NodeRemoveChange,
|
||||
nodeToRect,
|
||||
withResolvers,
|
||||
type Rect,
|
||||
} from '@xyflow/system';
|
||||
|
||||
@@ -280,7 +281,7 @@ export function useReactFlow<NodeType extends Node = Node, EdgeType extends Edge
|
||||
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>();
|
||||
const fitViewResolver = store.getState().fitViewResolver ?? withResolvers<boolean>();
|
||||
|
||||
// We schedule a fitView by setting fitViewQueued and triggering a setNodes
|
||||
store.setState({ fitViewQueued: true, fitViewOptions: options, fitViewResolver });
|
||||
|
||||
Reference in New Issue
Block a user