Skip to content

Commit 67d6683

Browse files
committed
reorded things
1 parent d1988d9 commit 67d6683

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

lessons/06-advanced-react/A-portals.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,14 @@ export default async function getPastOrder(order) {
6464
}
6565
```
6666

67-
Cool, let's go use this to render our Modal now. Open `past.lazy.jsx`. Make the `order.order_id` value a button and add an `onClick` event so clicking it will open the Modal:
68-
69-
```javascript
70-
<td>
71-
<button onClick={() => setFocusedOrder(order.order_id)}>
72-
{order.order_id}
73-
</button>
74-
</td>
75-
<td>{order.date}</td>
76-
<td>{order.time}</td>
77-
```
78-
7967
Then render the modal if we have a `focusedOrder`:
8068

8169
```javascript
8270
// import at top
8371
import getPastOrder from "../api/getPastOrder";
8472
import Modal from "../Modal";
8573

74+
// NOTE: In the course, Brian makes this a hook/module
8675
const intl = new Intl.NumberFormat("en-US", {
8776
style: "currency",
8877
currency: "USD",
@@ -135,7 +124,7 @@ const { isLoading: isLoadingPastOrder, data: pastOrderData } = useQuery({
135124
)}
136125
<button onClick={() => setFocusedOrder()}>Close</button>
137126
</Modal>
138-
) : null;
127+
) : null
139128
}
140129
```
141130

@@ -145,6 +134,19 @@ const { isLoading: isLoadingPastOrder, data: pastOrderData } = useQuery({
145134
- If there is a focusedOrder, we render the modal and show a loading indicator that we're loading the rest of the info.
146135
- When a user clicks Close, we set the focusedOrder to be undefined again which causes the Modal to unrender.
147136

137+
Finally, we need a way to open the modal. Open `past.lazy.jsx`. Make the `order.order_id` value a button and add an `onClick` event so clicking it will open the Modal:
138+
139+
```javascript
140+
<td>
141+
<button onClick={() => setFocusedOrder(order.order_id)}>
142+
{order.order_id}
143+
</button>
144+
</td>
145+
<td>{order.date}</td>
146+
<td>{order.time}</td>
147+
```
148+
149+
148150
That's it!
149151

150152
> 🏁 [Click here to see the state of the project up until now: 11-modals][step]

lessons/06-advanced-react/C-uncontrolled-forms.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ keywords:
1616

1717
We are now going to do a contact page for our site. As part of that, we will accept a name, email, and message from our users and submit it our backend. Like all good backends, ours will log it to the console and then ignore it.
1818

19-
We are going to see two new concepts here: how to do a post with TanStack Query (which they call a mutation) and how to do uncontrolled forms with React. Let's start with our API query. In src/api, create a file called postContact.js and put this in there.
19+
We are going to see two new concepts here: how to do a post with TanStack Query (which they call a mutation) and how to do uncontrolled forms with React. Let's start with our API query. In src/api, create a file called `postContact.js` and put this in there.
2020

2121
```javascript
2222
export default async function postContact(name, email, message) {
@@ -45,7 +45,7 @@ Create a new link to our page in index.lazy.jsx
4545
</li>
4646
```
4747

48-
Create a new route called contact.lazy.jsx in src/routes
48+
Create a new route called `contact.lazy.jsx` in `src/routes`
4949

5050
```javascript
5151
import { createLazyFileRoute } from "@tanstack/react-router";

0 commit comments

Comments
 (0)