Skip to content

Commit a0e6011

Browse files
committed
apply updates to following exercises
1 parent 0f92779 commit a0e6011

File tree

10 files changed

+32
-21
lines changed

10 files changed

+32
-21
lines changed

exercises/05.actions/01.problem.action-reference/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)

exercises/05.actions/01.solution.action-reference/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)

exercises/05.actions/02.problem.client/ui/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ function Root() {
6767
const fetchPromise = fetchContent(nextLocation)
6868
const nextContentPromise = createFromFetch(fetchPromise)
6969
contentCache.set(historyKey, nextContentPromise)
70+
startTransition(() => setContentKey(historyKey))
71+
} else {
72+
setContentKey(historyKey)
7073
}
71-
72-
startTransition(() => setContentKey(historyKey))
7374
}
7475
window.addEventListener('popstate', handlePopState)
7576
return () => window.removeEventListener('popstate', handlePopState)

exercises/05.actions/02.solution.client/ui/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ function Root() {
6868
const fetchPromise = fetchContent(nextLocation)
6969
const nextContentPromise = createFromFetch(fetchPromise)
7070
contentCache.set(historyKey, nextContentPromise)
71+
startTransition(() => setContentKey(historyKey))
72+
} else {
73+
setContentKey(historyKey)
7174
}
72-
73-
startTransition(() => setContentKey(historyKey))
7475
}
7576
window.addEventListener('popstate', handlePopState)
7677
return () => window.removeEventListener('popstate', handlePopState)

exercises/05.actions/03.problem.server/ui/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ function Root() {
6868
const fetchPromise = fetchContent(nextLocation)
6969
const nextContentPromise = createFromFetch(fetchPromise)
7070
contentCache.set(historyKey, nextContentPromise)
71+
startTransition(() => setContentKey(historyKey))
72+
} else {
73+
setContentKey(historyKey)
7174
}
72-
73-
startTransition(() => setContentKey(historyKey))
7475
}
7576
window.addEventListener('popstate', handlePopState)
7677
return () => window.removeEventListener('popstate', handlePopState)

exercises/05.actions/03.solution.server/ui/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ function Root() {
6868
const fetchPromise = fetchContent(nextLocation)
6969
const nextContentPromise = createFromFetch(fetchPromise)
7070
contentCache.set(historyKey, nextContentPromise)
71+
startTransition(() => setContentKey(historyKey))
72+
} else {
73+
setContentKey(historyKey)
7174
}
72-
73-
startTransition(() => setContentKey(historyKey))
7475
}
7576
window.addEventListener('popstate', handlePopState)
7677
return () => window.removeEventListener('popstate', handlePopState)

exercises/05.actions/04.problem.revalidation/ui/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ function Root() {
9898
const fetchPromise = fetchContent(nextLocation)
9999
const nextContentPromise = createFromFetch(fetchPromise)
100100
contentCache.set(historyKey, nextContentPromise)
101+
// 🐨 swap this with updateContentKey
102+
startTransition(() => setContentKey(historyKey))
103+
} else {
104+
// 🐨 swap this with updateContentKey
105+
setContentKey(historyKey)
101106
}
102-
103-
// 🐨 swap this with updateContentKey
104-
startTransition(() => setContentKey(historyKey))
105107
}
106108
window.addEventListener('popstate', handlePopState)
107109
return () => window.removeEventListener('popstate', handlePopState)

exercises/05.actions/04.solution.revalidation/ui/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ function Root() {
9696
const fetchPromise = fetchContent(nextLocation)
9797
const nextContentPromise = createFromFetch(fetchPromise)
9898
contentCache.set(historyKey, nextContentPromise)
99+
startTransition(() => updateContentKey(historyKey))
100+
} else {
101+
updateContentKey(historyKey)
99102
}
100-
101-
updateContentKey(historyKey)
102103
}
103104
window.addEventListener('popstate', handlePopState)
104105
return () => window.removeEventListener('popstate', handlePopState)

exercises/05.actions/05.problem.history-revalidation/ui/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ function Root() {
105105

106106
// if we don't have this key in the cache already, set it now
107107
contentCache.set(historyKey, nextContentPromise)
108+
startTransition(() => updateContentKey(historyKey))
109+
} else {
110+
updateContentKey(historyKey)
108111
}
109-
110-
updateContentKey(historyKey)
111112
}
112113
window.addEventListener('popstate', handlePopState)
113114
return () => window.removeEventListener('popstate', handlePopState)

exercises/05.actions/05.solution.history-revalidation/ui/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ function Root() {
102102
if (!contentCache.has(historyKey)) {
103103
// if we don't have this key in the cache already, set it now
104104
contentCache.set(historyKey, nextContentPromise)
105+
startTransition(() => updateContentKey(historyKey))
106+
} else {
107+
updateContentKey(historyKey)
105108
}
106-
107-
updateContentKey(historyKey)
108109
}
109110
window.addEventListener('popstate', handlePopState)
110111
return () => window.removeEventListener('popstate', handlePopState)

0 commit comments

Comments
 (0)