diff --git a/.changeset/mighty-seas-hang.md b/.changeset/mighty-seas-hang.md new file mode 100644 index 00000000..e8384b27 --- /dev/null +++ b/.changeset/mighty-seas-hang.md @@ -0,0 +1,5 @@ +--- +'@reactflow/core': minor +--- + +Add `edgesUpdatable` prop to store state. Allows enabling/disabling edge updating globally. diff --git a/packages/core/src/hooks/useUpdateNodeInternals.ts b/packages/core/src/hooks/useUpdateNodeInternals.ts index 849d76b6..9786c65c 100644 --- a/packages/core/src/hooks/useUpdateNodeInternals.ts +++ b/packages/core/src/hooks/useUpdateNodeInternals.ts @@ -6,13 +6,20 @@ import type { UpdateNodeInternals } from '../types'; function useUpdateNodeInternals(): UpdateNodeInternals { const store = useStoreApi(); - return useCallback((id: string) => { + return useCallback((id: string | string[]) => { const { domNode, updateNodeDimensions } = store.getState(); - const nodeElement = domNode?.querySelector(`.react-flow__node[data-id="${id}"]`) as HTMLDivElement; - if (nodeElement) { - requestAnimationFrame(() => updateNodeDimensions([{ id, nodeElement, forceUpdate: true }])); - } + const updateIds = Array.isArray(id) ? id : [id]; + + requestAnimationFrame(() => { + updateIds.forEach((updateId) => { + const nodeElement = domNode?.querySelector(`.react-flow__node[data-id="${updateId}"]`) as HTMLDivElement; + + if (nodeElement) { + updateNodeDimensions([{ id: updateId, nodeElement, forceUpdate: true }]); + } + }); + }); }, []); }