You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: react/advanced-hooks/03-transitions/practice/GUIDE.md
-24
Original file line number
Diff line number
Diff line change
@@ -2,30 +2,6 @@
2
2
3
3
This practice has three tabs where the rendering of the second tab is significantly slower than the others. If you click on the second tab and then immediately click to one the fast tabs you'll have to wait until the slow tab finishes first before you'll see your second clicked tab show.
4
4
5
-
Decide if `useTransition` or `useDeferredValue` is better suited to make this UI faster
6
-
7
-
Here is the syntax for each:
8
-
9
-
```js
10
-
/****************************************
11
-
useTransition
12
-
*****************************************/
13
-
const [pending, startTransition] =useTransition()
14
-
15
-
functionsomeEvent() {
16
-
setState() // high priority
17
-
startTransition(() => {
18
-
setState() // low priority
19
-
})
20
-
}
21
-
22
-
/****************************************
23
-
useDeferredValue
24
-
*****************************************/
25
-
const [myState, setMyState] =useState()
26
-
constmyStateDeferred=useDeferredValue(myState)
27
-
```
28
-
29
5
## Task 1
30
6
31
7
Make the UI faster by allowing the user to click on the slow tab then immediately click on a fast tab. Clicking the fast tab should show the fast tab soon instead of waiting for the slow tab to finish.
0 commit comments