throttle instead of debounce (#3168)
This commit is contained in:
@@ -715,14 +715,13 @@ function FlowRenderer({
|
|||||||
workflowChangesStore.setHasChanges(true);
|
workflowChangesStore.setHasChanges(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent cascading React updates
|
// throttle onNodesChange to prevent cascading React updates
|
||||||
if (onNodesChangeTimeoutRef.current) {
|
if (onNodesChangeTimeoutRef.current === null) {
|
||||||
clearTimeout(onNodesChangeTimeoutRef.current);
|
|
||||||
}
|
|
||||||
|
|
||||||
onNodesChangeTimeoutRef.current = setTimeout(() => {
|
|
||||||
onNodesChange(changes);
|
onNodesChange(changes);
|
||||||
}, 0); // defer to next tick
|
onNodesChangeTimeoutRef.current = setTimeout(() => {
|
||||||
|
onNodesChangeTimeoutRef.current = null;
|
||||||
|
}, 33); // ~30fps throttle
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
onEdgesChange={onEdgesChange}
|
onEdgesChange={onEdgesChange}
|
||||||
nodeTypes={nodeTypes}
|
nodeTypes={nodeTypes}
|
||||||
|
|||||||
Reference in New Issue
Block a user