File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -54,12 +54,13 @@ function Root() {
54
54
setNextLocation ( nextLocation )
55
55
// 🐨 get the historyKey from window.history.state?.key (or fallback to a new one with generateKey)
56
56
57
- // 🐨 if the contentCache does not have an entry for the historyKey, then trigger this update:
57
+ // 🐨 if the contentCache has an entry for the historyKey, then setContentKey(historyKey) directly.
58
+ // (⚠️ no startTransition needed here because the content is already available).
59
+ // 🐨 otherwise, fetch new content and wrap the update in startTransition:
58
60
const fetchPromise = fetchContent ( nextLocation )
59
61
const nextContentPromise = createFromFetch ( fetchPromise )
60
62
// 🐨 use the historyKey to add the nextContentPromise in the contentCache
61
-
62
- // 🐨 change this to setContentKey(historyKey)
63
+ // 🐨 and change this to setContentKey(historyKey)
63
64
startTransition ( ( ) => setContentPromise ( nextContentPromise ) )
64
65
}
65
66
window . addEventListener ( 'popstate' , handlePopState )
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {
11
11
} from 'react'
12
12
import { createRoot } from 'react-dom/client'
13
13
import * as RSC from 'react-server-dom-esm/client'
14
- import { contentCache , useContentCache , generateKey } from './content-cache.js'
14
+ import { contentCache , generateKey , useContentCache } from './content-cache.js'
15
15
import { ErrorBoundary } from './error-boundary.js'
16
16
import { shipFallbackSrc } from './img-utils.js'
17
17
import { RouterContext , getGlobalLocation , useLinkHandler } from './router.js'
You can’t perform that action at this time.
0 commit comments