brief git clarification / review
Why do we keep doing
git reset --hard
and
git checkout wX-stepY
like… what do these commands even do again...
1
git reset --hard
resets the LOCAL version of your code (on your computer) to match the version that’s stored in the CLOUD (on github)
irreversibly deletes all local (tracked) changes
2
3
4
many minutes later...
man… i wish i could just restore the code to the original working version but I’d have to press “undo” like 10,000 times and vscode won’t even let me do that...
git reset --hard
5
6
git checkout wX-stepY
retrieves the branch “wX-stepY” from the cloud (github)
7
going through version history of a google doc and selecting a specific version to “restore”
→ it’s the same idea!
8
we want to “check out” a particular version of the code.
(in this case, it’s an individual step of our workshop.)
9
hope that clarifies things a bit!
if you have more questions about git / version control, feel free to come to OH :)
10
Workshop 3 - More React, using APIs, and Routing
Shannen Wu + Claire Cheng
11
Previously...
12
Today!
13
API
GET
Getting started
14
Overview
15
Recall: component hierarchy before
16
App
Navbar
Profile
CatHappiness
Component hierarchy after today!
17
Card
Comments
Block
SingleStory
Feed
NewStory
App
Navbar
Profile
Single
Comment
New
Comment
CatHappiness
NotFound
Goals for today
18
Let’s go!
19
Starter!
20
Warmup
21
Warmup
22
Follow along: step 1
23
GET /api/stories
Returns all stories
Parameters: none
JSON.stringify(*list*) makes a list render-able
Follow along: step 1
24
Follow along: step 1
25
Your turn: step 2
26
Your turn: step 2
27
Your turn: step 2
28
Follow along: step 3
29
Review: the map function
30
{ id: 1, name: Matt } |
{ id: 2, name: Aaron } |
{ id: 3, name: Jessica } |
{ id: 4, name: Shannen } |
Provided function
(e.g. put item.name in a div)
<div> Matt </div> |
<div> Aaron </div> |
<div> Jessica </div> |
<div> Shannen </div> |
React CAN’T render this!
React CAN render this!
Follow along: step 3
31
Follow along: step 3
32
Follow along: step 3
33
That was GET, how about POST?
34
POST /api/story
Posts a new story
Parameters: content (string)
Follow along: step 4
35
POST /api/story
Posts a new story
Parameters: content (string)
Follow along: step 4
36
Follow along: step 4
resuming at 3:05 PM ET
37
resuming at 3:05 PM ET
38
Follow along: step 5
If you haven’t done this already…
39
App navigation?
40
Feed
App
Navbar
Profile
NotFound
App navigation?
41
App navigation?
42
URL
(address bar)
Router (component)
Render A (component)
Render B (component)
Render C (component)
- or-
- or-
Follow along: step 5
43
Follow along: step 5
44
Follow along: step 5
45
Steps 6-8
46
Steps 6-8
47
Previously:
GET /api/stories
Returns all stories
Parameters: none
POST /api/story
Posts a new story
Parameters: content
Now:
GET /api/comment
Returns all comments for a story
Parameters: parent (string)
POST /api/comment
Posts a new comment
Parameters: parent (string)
content
Follow along: Step 6
End of step 6
49
Your turn! Step 7
50
Your turn! Step 8
51
GET /api/comment
Returns all comments for a story
Parameters: parent (string)
POST /api/comment
Posts a new comment
Parameters: parent (string)
content
End of step 7
52
End of step 8
53
Your turn! Steps 6-8
54
Let’s get on the same page
55
Follow along: step 9
56
End of step 9
57
Final touches: step 10
58
Your turn: step 10
59
The end!
60
Homework: weblab.to/homework3
61