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

Commit 5e8d782

Browse files
author
Parth Shah
authored
Merge pull request #34 from githubtraining/fix-responses
fixed response formats
2 parents ca53ba4 + 608fa57 commit 5e8d782

11 files changed

+131
-201
lines changed

responses/00-setup.md

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,42 @@
1-
### Activity - Clone the repository and Install Node
2-
3-
Let's go ahead and get started.
4-
5-
First, clone this repository.
6-
7-
In your terminal, in a folder where you would like to keep this project, clone the repository, and do the following:
8-
9-
```
10-
cd intro-react
11-
git checkout changes
12-
```
13-
14-
Next, open the folder in your favorite text editor. We reccommend VSCode.
15-
16-
Great, now if you don't have Node installed on your computer, go ahead and [install it](https://nodejs.org/en/download/)!
17-
18-
Awesome!
19-
20-
### Current Functionality
21-
22-
Now, inside your repository folder, run the following:
23-
24-
```
25-
npm install
26-
npm start
27-
```
28-
29-
Your browser should open `http://localhost:3000/`
30-
31-
You'll see that our app can't really do anything! All we have is three buttons! We are going to add all the functionality.
321

2+
# Set up a React Application Locally
333

344
### So what's in our React App
35-
Let's take a look of what our React App looks like right now.
5+
Let's take a look of what our React App looks like right now. We will go through our file structure which is a [standard React setup](https://facebook.github.io/create-react-app/docs/getting-started). You will not be editing any files in this step, but the structure is important for future code references.
366

377
![File Structure](https://user-images.githubusercontent.com/25253905/61294641-28e68700-a78b-11e9-9bc1-ff468312ca8b.png)
388

399

40-
##### package.json
41-
42-
![package](https://user-images.githubusercontent.com/25253905/61294748-5e8b7000-a78b-11e9-9475-163d8c7bc6b3.png)
4310

11+
##### package.json
4412
This file is our roadmap of the app. It tells us the name of the app, the version, the different dependencies we need to run our app, and more.
4513

4614
##### public
4715

48-
This directory contains our `index.html` which directs us to the rest of the web application that requires additional processing.
16+
This directory contains our `index.html`. That file directs us to the rest of the web application that requires additional processing.
4917

5018
##### src
5119

52-
This is where pretty much ALL of your code will go. You'll notice we have `App.jsx` along with other `jsx` files, but what is `jsx`. Think of `jsx` as a mix between `html` and `javascript`. We can write tags as well as functions and classes. Take a look at `App.jsx`. Some of that stuff might look familiar from `html`, like thos `<div/>` tags. Don't worry, we will get to that stuff in a bit.
20+
This is where most of your code will go. You'll notice we have `App.jsx` along with other `jsx` files, but what is `jsx`. Think of `jsx` as a mix between `html` and `javascript`. We can write tags as well as functions and classes. Take a look at `App.jsx`. Some of that stuff might look familiar from `html`, like those `<div/>` tags. Don't worry, we will get to that stuff in a bit.
21+
22+
## Step 1: Set up locally
23+
In this repository, we have two branches - `master` and `changes`. We will be working off of the `changes` branch. Let's go ahead and get started.
24+
25+
### :keyboard: Activity: Clone the repository and install Node
26+
27+
1. Open your terminal
28+
2. Move into a location where you want to keep this project
29+
3. Clone this repository
30+
4. Move into the repository: `cd intro-react`
31+
5. Checkout to the `changes` branch: `git checkout changes`
32+
6. Open the `intro-react` folder in your favorite text editor
33+
- We recommend VSCode
34+
7. Check for Node installation: `node -v`
35+
8. [Install Node](https://nodejs.org/en/download/) if it is not installed
36+
9. In your repository folder, install the necessary packages: `npm install`
37+
10. Start the React Application: `npm start`
38+
39+
Your browser should automatically open `http://localhost:3000/`, and you should see our barebones gradebook application.
40+
41+
You'll see that our app can't really do anything! All we have is three buttons! We are going to add all the functionality.
5342

responses/01-components.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Content
2-
3-
## Building Blocks of ~~Life~~ Apps - Components
1+
# Building Blocks of ~~Life~~ Apps - Components
42

53
React apps are made up of components. Think of components as different parts of the app. Each button is a component, each text is a component etc. From html, you might recognize some of the built in components like `<div />` and `<li />`, but in React, we can create our own components! How cool is that?
64

5+
### Components in `App.jsx`
76
![Assignments Solution](https://user-images.githubusercontent.com/25253905/61293228-11f26580-a788-11e9-90ac-9612c2bddf6b.png)
87

9-
In our [solution](https://githubtraining.github.io/react-solution/), our assignments pages looks like the above. The overall webpage is a component that we call `App` and inside `App` there's are other components like buttons, titles, and even other custom components that we can create (like the Assginments List).
8+
In our [solution](https://githubtraining.github.io/react-solution/), our assignments page looks like the above. The overall webpage is a component that we call `App` and inside `App` there's are other components like buttons, titles, and even other custom components that we can create (like the Assginments List).
109

1110
Take a look at the following line in `App.jsx`.
1211

responses/02-props.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Content
2-
31
## How to Talk to your Child - Props
42

53
Alright, so we established that components are awesome, but what about reusable components with different properties?
@@ -10,6 +8,7 @@ Hmmm, but how do we pass different values to a component? We do so by passing pr
108

119
We will get a little deeper into that in a bit.
1210

11+
### Props used for Assignments and Students Pages
1312
![Finished Assignments Page](https://user-images.githubusercontent.com/25253905/61293228-11f26580-a788-11e9-90ac-9612c2bddf6b.png)
1413

1514
![Finished Students Page](https://user-images.githubusercontent.com/25253905/61293769-46b2ec80-a789-11e9-88b3-c660f436f5bf.png)
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Activity
2-
3-
### Add a state variable
1+
### Step 6 - Add a state variable
42

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

@@ -10,19 +8,15 @@ Currently, in `App`, we have three state variables:
108
- `assignments` - This stores the list of assignments. It is a state variable because the list changes every time a new assignment is added.
119
- `grades` - This should store the grade for each student. However, we have no way to store students, so let's fix that!
1210

13-
Add a state variable to `App` and name it `students`. Set it equal to an empty array. Make sure to add the comma!
14-
15-
### Run your code
16-
Run your code with `npm start` to make sure there are no errors.
17-
18-
19-
### Push your code
20-
21-
```
22-
git add src/App.jsx
23-
git commit -m "using students state variable and setting state"
24-
git push origin changes
11+
### :keyboard: Activity: Add a state variable to `App.jsx`
2512

26-
```
13+
1. Add a state variable to `App` and name it `students`. Set it equal to an empty array. Make sure to add the comma!
14+
2. Run your code with `npm start` to make sure there are no errors.
15+
3. Commit and push your code to the `changes` branch:
16+
```
17+
git add src/App.jsx
18+
git commit -m "import list component"
19+
git push origin changes
20+
```
2721
28-
I'll respond after you push.
22+
I'll respond after you push.
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
# Activity
2-
3-
### Bind the function
1+
### Step 8 - Binding a function
42

53
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.
64

7-
Go ahead and uncomment this line.
8-
9-
### Run your code
10-
Run your code with `npm start` to make sure there are no errors.
11-
12-
13-
### Push your code
5+
Go ahead and uncomment the line to bind `addStudent` to `App`.
146

15-
```
16-
git add src/App.jsx
17-
git commit -m "using students state variable and setting state"
18-
git push origin changes
7+
### :keyboard: Activity: Bind `addStudent` to `App`
198

20-
```
9+
1. Uncomment the line to bind `addStudent` to `App`.
10+
2. Run your code with `npm start` to make sure there are no errors.
11+
3. Commit and push your code to the `changes` branch:
12+
```
13+
git add src/App.jsx
14+
git commit -m "import list component"
15+
git push origin changes
16+
```
2117
22-
I'll respond after you push.
18+
I'll respond after you push.
Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1-
# Activity
1+
## Step 7 - Create an `addStudent` method
22

3-
### Create `addStudent` Function
3+
Now that we see how it works with assignments, let's try it with students! We will create an `addStudent` method to add students the same way we add assignments.
44

5-
Now that we see how it works with assignments, let's try it with students!
5+
### :keyboard: Activity: Import a List component to `App.jsx`
66

7-
create a method called `addStudent` below the comment
7+
1. Create a method called `addStudent` below the comment. `addStudent` should take `studentName` as a parameter and then concat that `studentName` to the end of `students` list that we created earlier.
8+
2. Run your code with `npm start` to make sure there are no errors.
9+
3. Commit and push your code to the `changes` branch:
10+
```
11+
git add src/App.jsx
12+
git commit -m "import list component"
13+
git push origin changes
14+
```
815
9-
`addStudent` should take `studentName` as a parameter and then concat that `studentName` to the end of `students` list that we created earlier.
10-
11-
### Run your code
12-
Run your code with `npm start` to make sure there are no errors.
13-
14-
15-
### Push your code
16-
17-
```
18-
git add src/App.jsx
19-
git commit -m "using students state variable and setting state"
20-
git push origin changes
21-
22-
```
23-
24-
I'll respond after you push.
16+
I'll respond after you push.
Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
1-
# Activity
1+
## Step 2: Adding components
22

3-
### Add a header component
4-
Let's add a couple of child components and give our app a header.
3+
Let's add a child component and give our app a header. At the end of the step, your app should like the following:
54

6-
On line 92 in `App.jsx`, replace the line where it says to replace with this header component:
7-
8-
```jsx
9-
<h3 className="Box-title d-flex flex-justify-center">GradeBook</h3>
10-
```
11-
12-
### Run your code
13-
To run your code, inside your repo folder in your termainal run `npm start`.
14-
15-
### What your code should look like
16-
17-
Your app should look like this!
185
![App with header](https://user-images.githubusercontent.com/25253905/61294086-eb352e80-a789-11e9-96ab-8b6cb09b3791.png)
196

20-
### Push your code
21-
Let's push your code to GitHub
7+
### :keyboard: Activity: Add an `h3` component to `App.jsx`
8+
9+
1. On line 92 in `App.jsx`, replace the line where it says to replace with this header component:
2210

23-
Run the following lines inside your repo folder in your terminal.
11+
```jsx
12+
<h3 className="Box-title d-flex flex-justify-center">GradeBook</h3>
13+
```
14+
2. Inside your repository folder in the terminal, run your code: `npm start`.
15+
3. Commit and push your code to the `changes` branch:
16+
```
17+
git add src/App.jsx
18+
git commit -m "added a header"
19+
git push origin changes
20+
```
2421

25-
```
26-
git add src/App.jsx
27-
git commit -m "added a header"
28-
git push origin changes
29-
```
22+
I'll respond after you push.
3023
31-
I'll respond after you push.
Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
# Activity
2-
3-
### Import a Child Component
1+
## Step 3 - Import a Child Component
42

53
Navigate to `List.jsx`. You'll see that we made our own component, `List`.
64

75
Let's go ahead and import that component.
86

9-
At the top of `App.jsx`, replace the line with
10-
11-
```js
12-
import List from "./List";
13-
```
14-
15-
Scroll down for the next step.
16-
17-
### Push your code
18-
Let's push your code to GitHub
7+
### :keyboard: Activity: Import a List component to `App.jsx`
198

20-
Run the following lines inside your repo folder in your terminal.
9+
1. At the top of `App.jsx`, replace the line with
2110

22-
```
23-
git add src/App.jsx
24-
git commit -m "import list component"
25-
git push origin changes
26-
```
11+
```js
12+
import List from "./List";
13+
```
14+
2. Commit and push your code to the `changes` branch:
15+
```
16+
git add src/App.jsx
17+
git commit -m "import list component"
18+
git push origin changes
19+
```
2720

28-
I'll respond after you push.
21+
I'll respond after you push.
Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
# Activity
2-
3-
### Replace the title prop in `List.jsx`
1+
## Step 5 - Adding a prop
42

53
But what does the `List` component do with this information? Let's take a look.
64

75
Go to `List.jsx`. In the `render` method, in our input tag, you see that we set our `placeholder` to `this.props.placeholder`, and then at the bottom of our `render` method, we loop through out `this.props.currList`, to show each item in the list that we pass. Adding `this.props` tells the component to look for that property that was passed to it.
86

9-
Let's go ahead and replace that title with a prop. In our `render` method in `List.jsx`, on line 31, where it says to replace the title with a prop, replace that with `{this.props.title}`.
10-
11-
### Run your code
12-
13-
To run your code, move inside your repo folder in your terminal and run `npm start`
14-
15-
### Push your code
16-
Awesome! We are using props! You already learned so much!
7+
Let's go ahead and replace that title with a prop.
178

18-
To push your code to Github, run the following lines inside the repo folder in your terminal.
9+
### :keyboard: Activity: Replace the title prop in `List.jsx`
1910

20-
```
21-
git add src/List.jsx
22-
git commit -m "using props for List component"
23-
git push origin changes
24-
```
11+
1. In our `render` method in `List.jsx`, on line 31, where it says to replace the title with a prop, replace that with `{this.props.title}`
12+
2. To run your code, move inside your repo folder in your terminal and run `npm start`
13+
3. Commit and push your code to the `changes` branch:
14+
```
15+
git add src/App.jsx
16+
git commit -m "import list component"
17+
git push origin changes
18+
```
2519
26-
I'll respond after you push.
20+
I'll respond after you push.

0 commit comments

Comments
 (0)