diff --git a/exercises/05.actions/05.problem.history-revalidation/ui/index.js b/exercises/05.actions/05.problem.history-revalidation/ui/index.js index 01a2730..33e1400 100644 --- a/exercises/05.actions/05.problem.history-revalidation/ui/index.js +++ b/exercises/05.actions/05.problem.history-revalidation/ui/index.js @@ -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)) { diff --git a/exercises/05.actions/05.solution.history-revalidation/ui/index.js b/exercises/05.actions/05.solution.history-revalidation/ui/index.js index 3c82755..bf7acae 100644 --- a/exercises/05.actions/05.solution.history-revalidation/ui/index.js +++ b/exercises/05.actions/05.solution.history-revalidation/ui/index.js @@ -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)