Skip to content

Commit 62b0edd

Browse files
fix: Avoid unnecessary startTransition on cached popstate navigations
1 parent 350493d commit 62b0edd

File tree

1 file changed

+3
-2
lines changed
  • exercises/04.router/05.solution.cache/ui

1 file changed

+3
-2
lines changed

exercises/04.router/05.solution.cache/ui/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ function Root() {
5656
const fetchPromise = fetchContent(nextLocation)
5757
const nextContentPromise = createFromFetch(fetchPromise)
5858
contentCache.set(historyKey, nextContentPromise)
59+
startTransition(() => setContentKey(historyKey))
60+
} else {
61+
setContentKey(historyKey)
5962
}
60-
61-
startTransition(() => setContentKey(historyKey))
6263
}
6364
window.addEventListener('popstate', handlePopState)
6465
return () => window.removeEventListener('popstate', handlePopState)

0 commit comments

Comments
 (0)