throttle instead of debounce (#3168)

This commit is contained in:
Jonathan Dobson
2025-08-12 19:32:39 -04:00
committed by GitHub
parent 48ccd5fd72
commit 1148894e48

View File

@@ -715,14 +715,13 @@ function FlowRenderer({
workflowChangesStore.setHasChanges(true);
}
// prevent cascading React updates
if (onNodesChangeTimeoutRef.current) {
clearTimeout(onNodesChangeTimeoutRef.current);
}
onNodesChangeTimeoutRef.current = setTimeout(() => {
// throttle onNodesChange to prevent cascading React updates
if (onNodesChangeTimeoutRef.current === null) {
onNodesChange(changes);
}, 0); // defer to next tick
onNodesChangeTimeoutRef.current = setTimeout(() => {
onNodesChangeTimeoutRef.current = null;
}, 33); // ~30fps throttle
}
}}
onEdgesChange={onEdgesChange}
nodeTypes={nodeTypes}