Skip to content

Commit 1eddf7f

Browse files
committed
Enhance React Task Manager lesson with additional comments and code annotations for clarity
1 parent 263f95f commit 1eddf7f

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

module2/lessons/react_task_manager.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module: 3
1717
## Before you get started...
1818

1919
<section class="note">
20-
This tutorial was repurposed from another Tutorial called IdeaBox, therefore, names have been updated for Task Manager. Provided images are there as reference.
20+
This tutorial was repurposed from another tutorial called IdeaBox, therefore, names have been updated for Task Manager. Provided images are there as reference.
2121
</section>
2222

2323
You will complete this lesson on your own. Read each section carefully and completely. Moving quickly through this lesson is **not** the goal. You should move through the lesson at a pace that allows you to take solid notes and fully understand the code you are writing. We will provide lots of code blocks for you. Resist the temptation to copy and paste the code from those examples. Doing this will only hurt you in the end, as you'll be missing out on a lot, a lot, a lot of learning.
@@ -118,6 +118,8 @@ You'll also notice an `main.jsx` file. What is going on in there?
118118
This is a great time to do some googling or ask chatGPT for help understanding.
119119

120120
```jsx
121+
// main.jsx
122+
121123
createRoot(document.getElementById("root")).render(
122124
<StrictMode>
123125
<App />
@@ -188,6 +190,8 @@ We will use **_state_** to store data, like our list of tasks. You learned about
188190
In order to use component state, we need to import useState hook from React. So, let's import useState hook from React, and create our App component!
189191

190192
```jsx
193+
// App.jsx
194+
191195
import { useState } from 'react';
192196

193197
function App() {
@@ -209,6 +213,8 @@ The above code is defining the App functional component in React. App returns JS
209213
Let's keep writing our App component!
210214

211215
```jsx
216+
// App.jsx
217+
212218
import { useState } from "react";
213219

214220
function App() {
@@ -236,6 +242,8 @@ JSX is "JavaScript and XML" - it's a handy mashup language that allows us to wri
236242
Okay. Now try to add a paragraph tag after your `<h1>` tag. What happened?
237243

238244
```jsx
245+
// App.jsx
246+
239247
import { useState } from "react";
240248

241249
function App() {
@@ -281,6 +289,8 @@ If you're just looking for an unflavored container for your elements (aka they a
281289
We'll also import our App.css file. And give our <main> element a class of 'App' like so:
282290

283291
```jsx
292+
// App.jsx
293+
284294
import { useState } from "react";
285295
import "./App.css";
286296

@@ -303,6 +313,8 @@ You'll notice that instead of "`class`", we're using a "`className`" attribute o
303313
Okay. Let's come back to our App component and create _state_ - our "source of truth" for the data the app will be using.
304314

305315
```jsx
316+
// App.jsx
317+
306318
import { useState } from "react";
307319
import "./App.css";
308320

@@ -333,6 +345,8 @@ For our application, we want to create a list (aka an array) of tasks.
333345
Let's start out with a couple of default tasks, just so we can have something to look at when we begin building out the rest of our components.
334346

335347
```jsx
348+
// App.jsx
349+
336350
import { useState } from "react";
337351
import "./App.css";
338352

@@ -461,6 +475,7 @@ In our App component's return statement, let's get rid of our <p> tag and pass s
461475

462476
```jsx
463477
// App.jsx
478+
464479
// ...
465480
return (
466481
<main className="App">
@@ -807,6 +822,8 @@ import Form from "../Form/Form";
807822
Then, render the Form in App's return.
808823

809824
```jsx
825+
// App.jsx
826+
810827
return (
811828
<main className="App">
812829
<h1>Task Manager</h1>
@@ -1150,6 +1167,7 @@ Now, let's modify our `App.jsx` file to use these API calls instead of the hard-
11501167

11511168
```jsx
11521169
// App.jsx
1170+
11531171
import "./App.css";
11541172
import Tasks from "../Tasks/Tasks";
11551173
import Form from "../Form/Form";
@@ -1219,6 +1237,8 @@ Let's break down the changes we've made:
12191237
The `useEffect` hook allows us to perform side effects in our components. In this case, we're using it to fetch data from our API when the component first renders.
12201238

12211239
```jsx
1240+
// App.jsx
1241+
12221242
useEffect(() => {
12231243
const fetchTasks = async () => {
12241244
try {
@@ -1307,6 +1327,8 @@ To test your API integration:
13071327
2. In `app/config/initializers/cors.rb`, ensure you whitelist your React app as a trusted source:
13081328

13091329
```ruby
1330+
# app/config/initializers/cors.rb
1331+
13101332
Rails.application.config.middleware.insert_before 0, Rack::Cors do
13111333
allow do
13121334
origins "localhost:5173"

0 commit comments

Comments
 (0)