Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit 2bb9a92

Browse files
committed
more edits to responses after bug stuck
1 parent 1833263 commit 2bb9a92

11 files changed

+53
-61
lines changed
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1-
### Step 6: Add a state variable
1+
## State variables
22

33
In React, we store dynamic data in **state variables**. Let's take a look at how we store state variables. In `src/App.jsx`, take a look at the constructor. You'll see that we declare our state variables using `this.state = {.....}`.
44

5-
65
Currently, in `App`, we have three state variables:
76
- `buttonClicked` - This stores which button was clicked. It is a state variable because the button that is clicked has the ability to change.
87
- `assignments` - This stores the list of assignments. It is a state variable because the list changes every time a new assignment is added.
98
- `grades` - This should store the grade for each student. However, we have no way to store students, so let's fix that!
109

10+
## Step 6: Add a state variable
11+
12+
Let's add a way to store students as a variable.
13+
1114
### :keyboard: Activity: Add a state variable to `src/App.jsx`
1215

13-
1. On line 11, add a state variable named `students`
16+
1. On line 11 of `src/App.jsx`, add a state variable named `students`
1417
2. Set `students` equal to an empty array
1518
3. Add a comma: `students: [],`
16-
4. Save your code
19+
4. Save your changes
1720
5. To run your code, move inside your repo folder in your terminal and run `npm start`
1821
6. Exit the process in your terminal using `Ctrl + C`
19-
7. Commit and push your code to the `changes` branch:
22+
7. Stage, commit, and push your changes to the `changes` branch:
2023
```
2124
git add src/App.jsx
2225
git commit -m "add a state variable for students"
2326
git push
2427
```
2528
2629
<hr>
27-
<h3 align="center">Watch below this comment for my response</h3>
30+
<h3 align="center">Watch below this comment for my response.</h3>

responses/05_state.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
## A Date with Data - State Variables
1+
## State Variables
22

33
So now, we learned how to pass data to components, but let's talk about the data itself.
44

55
There are two types of data: **static data** and **dynamic data**.
66

7-
Static data doesn't change, hence the name static. Things like a title on a page or the name of a button would be static data.
8-
9-
Dynamic data, on the other hand, is data that does change because we can change it by adding an item to the list. Our list of assignments would be considered dynamic data. But how do we deal with dynamic data in React? We can't just dump it in a component, because how will we tell the data to change?
7+
Static data doesn't change. Things like a title on a page or the name of a button would be static data.
108

9+
Dynamic data, on the other hand, is data that does change. In our example, we can change it by adding an item to the list. Our list of assignments would also be considered dynamic data. But, how do we deal with dynamic data in React?
1110

1211
Scroll below to take a look in the code!

responses/06_create-addstudent-activity.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ Now that we see how it works with assignments, let's try it with students! We wi
44

55
### :keyboard: Activity: Create an `addStudent` method in `src/App.jsx`
66

7-
1. On line 37, create a method called `addStudent` below the comment
8-
- `addStudent` should take `studentName` as a parameter
9-
- `addStudent` should concat `studentName` to the end of `students` list that we created earlier
7+
1. On line 37 of `src/App.jsx`, create a method called `addStudent` below the comment
8+
- `addStudent` should take `studentName` as a parameter
9+
- `addStudent` should concat `studentName` to the end of `students` list that we created earlier
1010
- **Hint**: You can copy the same format for the `addAssignment` method
11-
2. Save your code
11+
2. Save your changes
1212
3. To run your code, move inside your repo folder in your terminal and run `npm start`
1313
4. Exit the process in your terminal using `Ctrl + C`
14-
5. Commit and push your code to the `changes` branch:
14+
5. Stage, commit, and push your changes to the `changes` branch:
1515
```
1616
git add src/App.jsx
1717
git commit -m "create addStudents method"
1818
git push
1919
```
2020
2121
<hr>
22-
<h3 align="center">Watch below this comment for my response</h3>
22+
<h3 align="center">Watch below this comment for my response.</h3>

responses/06_explaining-this-state-activity.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
### Explaining `this.setState`
22

3-
Ok, so now we added a state variable, how do we actually change the data?
3+
How do we change data within a state variable?
44

5-
Unfortunatley, we can't just do `this.state.studentsList = .....` to change data.
5+
Unfortunately, we can't just do `this.state.studentsList = .....` to change data.
66

77
To set the state of a state variable we have to use the method, `this.setState`.
88

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
### Step 8: Binding a method
1+
## Step 8: Binding a method
22

3-
Also, since we created a method that changes the a state variable, we have to bind it to our class, so that when we call it, we know what method to reference.
4-
5-
Go ahead and uncomment the line to bind `addStudent` to `App`.
3+
Since we created a method that changes a state variable, we have to bind it to our class. Then, when we call it, we know what method to reference.
64

75
### :keyboard: Activity: Bind `addStudent` to `App`
86

9-
1. On line 19, uncomment the line to bind `addStudent` to `App`
10-
2. Save your code
7+
1. Uncomment line 18 of `src/App.jsx` to bind `addStudent` to `App`
8+
2. Save your changes
119
3. To run your code, move inside your repo folder in your terminal and run `npm start`
1210
4. Exit the process in your terminal using `Ctrl + C`
13-
3. Commit and push your code to the `changes` branch:
11+
5. Stage, commit, and push your changes to the `changes` branch:
1412
```
1513
git add src/App.jsx
1614
git commit -m "bind addStudent to App"
1715
git push
1816
```
1917
2018
<hr>
21-
<h3 align="center">Watch below this comment for my response</h3>
19+
<h3 align="center">Watch below this comment for my response.</h3>

responses/08_callbackfunctions.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
## Throwing it Back - Callback Functions
1+
## Callback Functions
22

3-
The last thing you need to know before you can call yourself a React Developer is callback functions. We said that we can pass data to the child with `props`, but what about passing data from the child to the parent?
3+
The last thing you need to know before you can call yourself a React Developer is callback functions. We said that we can pass data to the child with `props`, but what about passing data from the child to the parent?
44

5-
With **callback functions**, we are able to do just that. Basically, we **pass a function as a prop**, and then the child component can call the function that was defined in the parent. Yeah, that's confusing. Let's look at an example.
6-
7-
Scroll Below!
5+
With **callback functions**, we are able to do just that. We **pass a function as a prop**, and then the child component can call the function that was defined in the parent. Let's look at an example below.
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
## Step 9: Adding the correct props
22

3-
Take a look at this conditional between lines 71 and 80 in `src/App.jsx`.
3+
There are some issues with this code. We want to be modifying the `students` list, not the `assignments` list.
44

5-
We are trying to render the correct component when we click `Students`.
6-
7-
There are some issues with this code. We want to be modifying the `students` list, not the `assignments` list.
8-
9-
Let's go ahead and change some props!
5+
Let's change some props between lines 71 and 80 to render the correct components when we click `Students`.
106

117
### :keyboard: Activity: Change the props for Students
128

13-
1. Uncomment the conditional statement between lines 71 and 80
14-
2. On line 74, change the `placeholder` prop to `"Add Student..."`
15-
3. On line 75, change the `currList` prop to `{this.state.students}`
16-
4. On line 76, change the `addFunction` prop to `{this.addStudent}`
17-
5. Save your code
9+
1. Uncomment the conditional statement between lines 65 and 75 of `src/App.jsx`
10+
2. On line 68, change the `placeholder` prop to `"Add Student..."`
11+
3. On line 69, change the `currList` prop to `{this.state.students}`
12+
4. On line 70, change the `addFunction` prop to `{this.addStudent}`
13+
5. Save your changes
1814
6. To run your code, move inside your repo folder in your terminal and run `npm start`
1915
7. Exit the process in your terminal using `Ctrl + C`
20-
8. Commit and push your code to the `changes` branch:
16+
8. Stage, commit, and push your changes to the `changes` branch:
2117
```
2218
git add src/App.jsx
2319
git commit -m "change props for students rendering"
2420
git push
2521
```
2622
2723
<hr>
28-
<h3 align="center">Watch below this comment for my response</h3>
24+
<h3 align="center">Watch below this comment for my response.</h3>
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
### Look at an example of passing functions as props
1+
### Example of passing functions as props
22

33
So where exactly are those functions we created to set state getting called?
44

55
On line 63 in `src/App.jsx`, it looks like we pass the `addAssignment` function as a prop in this chunk of code.
66

7-
Navigate to `src/List.jsx`
8-
9-
Let's take a look at this piece of code between lines 18 and 25 in `src/List.jsx`.
7+
Navigate to `src/List.jsx` and take a look at the code between lines 18 and 25 in `src/List.jsx`.
108

119
```jsx
1210
handleSubmit(event) {
@@ -19,6 +17,6 @@ handleSubmit(event) {
1917
}
2018
```
2119

22-
It looks like when the submit button is clicked, we call the `addFunction` with the value of our input box. For assignments, this `addFunction` references the `this.addAssignment` in `App`. So when we call `this.props.addFunction`, we are calling back to the parent component and using the parent's function.
20+
When the submit button is clicked, we call the `addFunction` with the value of our input box. For assignments, the `addFunction` references the `this.addAssignment` in `App`. So when we call `this.props.addFunction`, we are calling back to the parent component and using the parent's function.
2321

24-
Scroll below for next steps!
22+
Scroll below for next steps.
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
## Step 10: Uncomment the Grades Section
2-
3-
LAST THING! Let's get our grades working! At the end of this activity, your code should now be able to add assignments, students, and grades! You will be done!
1+
## Step 10: Include Grades
42

3+
Let's get our grades working! At the end of this activity, your code should now be able to add assignments, students, and grades.
54

65
### :keyboard: Activity: Uncomment the grades conditional in `src/App.jsx`
76

8-
1. Uncomment the conditional statment between lines 83 and 92 for our `grades` tab
9-
2. Save your code
7+
1. In the `src/App.jsx` file, uncomment the conditional statement between lines 77 and 86 for our `grades` tab
8+
2. Save your changes
109
3. To run your code, move inside your repo folder in your terminal and run `npm start`
1110
4. Exit the process using `Ctrl + C`
12-
5. Commit and push your code to the `changes` branch:
11+
5. Stage, commit, and push your changes to the `changes` branch:
1312
```
1413
git add src/App.jsx
1514
git commit -m "uncomment grades section"
1615
git push
1716
```
1817
1918
<hr>
20-
<h3 align="center">Watch below this comment for my response</h3>
19+
<h3 align="center">Watch below this comment for my response.</h3>

responses/10_approve.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
## Step 11: Merge your pull request
22

3-
We have approved all of your chages
3+
Now that we've approved the changes, it's time to merge the pull request.
44

55
### :keyboard: Activity: Merge the `changes` branch into `master`
6+
67
1. Click the `Merge Pull Request` button
78

89
<hr>
9-
<h3 align="center">Watch below this comment for my response</h3>
10+
<h3 align="center">Watch below this comment for my response.</h3>

0 commit comments

Comments
 (0)