git checkout -b #FIRSTNAMEHERE#
npm install
npm run start
- Your server will run on
localhost:3004/dogs
. Your React frontend will run onlocalhost:3000
- Your server at
localhost:3004/dogs
returns a response that looks like this:
[
{
"image": "https://images.dog.ceo/breeds/labradoodle/Cali.jpg",
"likes": 0,
"id": 1,
"name": "Rover"
},
{
"image": "https://images.dog.ceo/breeds/beagle/n02088364_16689.jpg",
"likes": 0,
"id": 2,
"name": "Bingo"
},
]
- DELIVERABLE 1: Write code in
App.js
that fetches all dogs from the server and then renders them inside in thediv
with theid
ofdogs
. Each dog should be represented in an individual div that looks like:
<div className="dog">
<img src="#IMAGE HERE#" alt="#NAME HERE#">
<p>#NAME HERE#</p>
<p>Likes: #LIKES HERE#</p>
<button>Like</button>
</div>
-
DELIVERABLE 2: Refactor the code so that each
Dog
now has it's own component that is imported toApp.js
and passed props in order to render it. In addition to the server data, create a functionaddLike
that will add a like to a particular dog (only locally, no persistence needed). -
DELIVERABLE 3: Update the event handler for the
select
dropdown so it now filters successfully betweenAll Dogs
and dogs with one or more likes orLiked Dogs
. If there are no dogs to show, instead of showing nothing show an<h2>
with the phraseNo Dogs To Show ;(
. -
DELIVERABLE 4: Refactor your
addLike
function so that it now makes aPATCH
request tohttp://localhost:3004/dogs/:id
where the id is the ID of the dog you wish to change. The body of the request (before JSON.stringify) should look like:
{"likes": "#NEW NUMBER OF LIKES HERE#"}
After doing this, you should be able to refresh the page and the likes should persist.
git add . && git commit -m "#PUT TIME HERE#"
git checkout -b deliverable-#NUMBER OF DELIVERABLE HERE#
- Check out what you need to check out, maybe copy/paste somewhere.
- When you're done, to return to your work:
git stash && git checkout #FIRSTNAMEHERE#