From 1cff694df25947441dd2ce641c6921dc869fdc9b Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Mon, 5 Jul 2021 15:23:44 +0200 Subject: [PATCH] Perf tweak --- packages/dataverse-react/src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/dataverse-react/src/index.ts b/packages/dataverse-react/src/index.ts index 79eafa2..e03e733 100644 --- a/packages/dataverse-react/src/index.ts +++ b/packages/dataverse-react/src/index.ts @@ -127,7 +127,9 @@ function queueIfNeeded() { let i = 0 while (queue.length > 0) { i++ - if (i > 5) { + if (i === 4) { + // react might be skipping updates, perhaps in concurrent mode. + //we can recheck the queue later setTimeout(queueIfNeeded, 1) break } @@ -135,7 +137,7 @@ function queueIfNeeded() { for (const item of queue) { item.runUpdate() } - }) + }, 1) } microtaskIsQueued = false })