defer flow updates to next tick (#3211)
This commit is contained in:
@@ -619,12 +619,13 @@ function FlowRenderer({
|
|||||||
) {
|
) {
|
||||||
workflowChangesStore.setHasChanges(true);
|
workflowChangesStore.setHasChanges(true);
|
||||||
}
|
}
|
||||||
// throttle onNodesChange to prevent cascading React updates
|
// defer update to next tick to prevent max recursion errors;
|
||||||
|
// NOTE: deferring too long causes node updates to be skipped
|
||||||
if (onNodesChangeTimeoutRef.current === null) {
|
if (onNodesChangeTimeoutRef.current === null) {
|
||||||
onNodesChange(changes);
|
onNodesChange(changes);
|
||||||
onNodesChangeTimeoutRef.current = setTimeout(() => {
|
onNodesChangeTimeoutRef.current = setTimeout(() => {
|
||||||
onNodesChangeTimeoutRef.current = null;
|
onNodesChangeTimeoutRef.current = null;
|
||||||
}, 33); // ~30fps throttle
|
}, 0);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onEdgesChange={onEdgesChange}
|
onEdgesChange={onEdgesChange}
|
||||||
|
|||||||
Reference in New Issue
Block a user