Skip to content

Commit 9232a63

Browse files
committed
improve instructions
1 parent 2d65237 commit 9232a63

File tree

7 files changed

+31
-26
lines changed

7 files changed

+31
-26
lines changed

β€Žexercises/04.context/01.problem.provider/README.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Context Provider
22

3-
πŸ§β€β™‚οΈ I was refactoring things a bit and decided we shouldn't need to pass
4-
the `query` and `setSearchParams` as props. Instead I just wanted to call
5-
`useSearchParams` in each of the components that need them (there's only one
6-
URL afterall).
3+
πŸ§β€β™‚οΈ I was <PrevDiffLink>refactoring things</PrevDiffLink> a bit and decided we
4+
shouldn't need to pass the `query` and `setSearchParams` as props. Instead I
5+
just wanted to call `useSearchParams` in each of the components that need them
6+
(there's only one URL afterall).
77

88
Well that didn't work. Turns out we now have multiple instances of the search
99
params state and multiple subscriptions to the `popstate` event. That's not

β€Žexercises/04.context/02.problem.hook/README.mdx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Context Hook
22

33
πŸ§β€β™‚οΈ I was playing around with the app and I realized that we have a default value
4-
for our context provider. So I thought maybe we could remove the context
5-
provider. Unfortunately that didn't work. Do you know why?
4+
for our context provider. So I thought maybe we
5+
could <PrevDiffLink>remove the context</PrevDiffLink> provider. Unfortunately
6+
that didn't work. Do you know why?
67

78
πŸ‘¨β€πŸ’Ό Yeah, it's because even though the `searchParams` are shared, they're not
89
updated when calling `setSearchParams`. This is because the `searchParams`

β€Žexercises/05.portals/01.problem.create/README.mdx

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
πŸ‘¨β€πŸ’Ό Some of our users find the heart icon to be unclear and would like to have a
44
tooltip that explains what it's for.
55

6-
πŸ§β€β™‚οΈ I've moved things around a little bit to reduce the amount of code you need
7-
to work in. I've also added a simple tooltip component that's not working quite
8-
yet. The positioning is all funny because the tooltip is being rendered within
9-
the context of the card instead of at the root of the document.
6+
πŸ§β€β™‚οΈ I've <PrevDiffLink>moved things around a little bit</PrevDiffLink> to reduce
7+
the amount of code you need to work in. I've also added a simple tooltip
8+
component that's not working quite yet. The positioning is all funny because the
9+
tooltip is being rendered within the context of the card instead of at the root
10+
of the document.
1011

1112
πŸ‘¨β€πŸ’Ό Thanks Kellie. Now, let's see if you can make the tooltip component work
1213
properly with a portal.

β€Žexercises/06.layout-computation/01.problem.layout-effect/README.mdx

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ That `height` is used to determine whether the tooltip should appear above or
1616
below the target element (the heart in our case).
1717

1818
Kellie πŸ§β€β™‚οΈ noticed on low-end devices, they're seeing a little flicker
19-
so <DiffLink app1={-1}>she's added</DiffLink> an arbitrary slowdown to our
19+
so <PrevDiffLink>she's added</PrevDiffLink> an arbitrary slowdown to our
2020
component to simulate that problem. To reproduce the problem, simply hover over
2121
a heart and you'll notice it starts at the bottom of the heart and then flickers
2222
to the top (if there's room on the top of the heart).
@@ -25,3 +25,6 @@ So your job is simple. Change `useEffect` to `useLayoutEffect` and that should
2525
fix things.
2626

2727
πŸ“œ Parts of this exercise was lifted from [the React docs](https://react.dev/reference/react/useLayoutEffect#measuring-layout-before-the-browser-repaints-the-screen)
28+
29+
πŸ“œ Learn more about the difference between `useEffect` and `useLayoutEffect` in
30+
[useEffect vs useLayoutEffect](https://kentcdodds.com/blog/useeffect-vs-uselayouteffect).
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# useImperativeHandle
22

3-
πŸ‘¨β€πŸ’Ό We've got a new thing for you to work on. Kellie πŸ§β€β™‚οΈ put together a
4-
`Scrollable` component which is a wrapper around a `div` that has a way to
5-
scroll to the top and bottom of the content. We want to be able to add buttons
6-
to the `App` that will allow users to scroll to the top and bottom of the
7-
content when clicked.
3+
πŸ‘¨β€πŸ’Ό We've got a new thing for you to work on.
84

9-
So we need you to `useImperativeHandle` to expose a `scrollToTop` and
5+
πŸ§β€β™‚οΈ I've put together a `Scrollable` component which is a wrapper around a `div`
6+
that has a way to scroll to the top and bottom of the content. We want to be
7+
able to add buttons to the `App` that will allow users to scroll to the top and
8+
bottom of the content when clicked.
9+
10+
πŸ‘¨β€πŸ’Ό So we need you to `useImperativeHandle` to expose a `scrollToTop` and
1011
`scrollToBottom` method from the `Scrollable` component. These methods are
1112
already implemented, you just need to expose them.

β€Žexercises/08.focus/README.mdx

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ update. For example:
1010

1111
```tsx
1212
function MyComponent() {
13-
const inputRef = useRef<HTMLInputElement>(null)
1413
const [show, setShow] = useState(false)
1514

1615
return (
1716
<div>
1817
<button onClick={() => setShow(true)}>Show</button>
19-
{show && <input ref={inputRef} />}
18+
{show ? <input /> : null}
2019
</div>
2120
)
2221
}
@@ -49,7 +48,7 @@ function MyComponent() {
4948
>
5049
Show
5150
</button>
52-
{show && <input ref={inputRef} />}
51+
{show ? <input ref={inputRef} /> : null}
5352
</div>
5453
)
5554
}
@@ -80,7 +79,7 @@ function MyComponent() {
8079
>
8180
Show
8281
</button>
83-
{show && <input ref={inputRef} />}
82+
{show ? <input ref={inputRef} /> : null}
8483
</div>
8584
)
8685
}
@@ -93,4 +92,4 @@ to focus it on the line following the `flushSync` call.
9392
In general you want to avoid this de-optimization, but in some cases (like focus
9493
management), it's the perfect solution.
9594

96-
Learn more in [the `flushSync` docs](https://react.dev/reference/react-dom/flushSync).
95+
Learn more in [πŸ“œ the `flushSync` docs](https://react.dev/reference/react-dom/flushSync).

β€Žexercises/09.sync-external/03.problem.ssr/README.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
πŸ‘¨β€πŸ’Ό We don't currently do any server rendering, but in the future we may want to
44
and this requires some special handling with `useSyncExternalStore`.
55

6-
πŸ§β€β™‚οΈ I've simulated a server rendering environment by adding some code to the
7-
bottom of our file. First, we render the `<App />` to a string, then we set that
8-
to the `innerHTML` of our `rootEl`. Then we call `hydrateRoot` to rehydrate our
9-
application.
6+
πŸ§β€β™‚οΈ <PrevDiffLink>I've simulated a server rendering environment</PrevDiffLink> by
7+
adding some code to the bottom of our file. First, we render the `<App />` to a
8+
string, then we set that to the `innerHTML` of our `rootEl`. Then we call
9+
`hydrateRoot` to rehydrate our application.
1010

1111
πŸ‘¨β€πŸ’Ό This is a bit of a hack, but it's a good way to simulate server rendering
1212
and ensure that our application works in a server rendering situation.

0 commit comments

Comments
Β (0)