Skip to content

Commit

Permalink
transitions yo
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed May 20, 2024
1 parent 844b223 commit 0d4ca7f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,10 @@ function Root() {
setNextLocation(nextLocation)
const historyKey = window.history.state?.key ?? generateKey()

// 🐨 handle race conditions for this revalidation similar to what we do
// in navigate below with the latestNav ref.

// 🐨 declare "let nextContentPromise" here
// 🐨 move the fetchPromise up from the if statement below because now we're going to revalidate all the time
// 🐨 when the fetchPromise stream is finished (💰 onStreamFinished):
// set the historyKey in the contentCache to nextContentPromise
// set the historyKey in the contentCache to nextContentPromise in a startTransition
// 🐨 assign nextContentPromise to createFromFetch(fetchPromise)

if (!contentCache.has(historyKey)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,10 @@ function Root() {
setNextLocation(nextLocation)
const historyKey = window.history.state?.key ?? generateKey()

const thisNav = Symbol(`Popstate for ${nextLocation}`)
latestNav.current = thisNav

let nextContentPromise
const fetchPromise = fetchContent(nextLocation)
onStreamFinished(fetchPromise, () => {
contentCache.set(historyKey, nextContentPromise)
startTransition(() => contentCache.set(historyKey, nextContentPromise))
})
nextContentPromise = createFromFetch(fetchPromise)

Expand Down

0 comments on commit 0d4ca7f

Please sign in to comment.