Dino Blog Activity
Lab: Dino Blog
Part 1
Let's have some practice creating a React component from scratch. How about a blog post?
Change directories to
labs
where you're going to create the next projectCreate a repo called
dino-blog
( make it public ). Add aREADME.md
.Clone down your
dino-blog
repo.cd
intodino-blog
and add react
If you need to refresh your memory, refer below or view the official create-react-app
Github repository.
Note: If you are running something else on port 3000 - like a Node app or another React app, you may get prompted to use 3001 or specify a new port. You can do this or you can kill the process that's already running.
Part 2
Create a
dino
object insrc/App.js
that has the following properties:title
(example value:"Dinosaurs are awesome"
)author
(example value:"Stealthy Stegosaurus"
)body
(example value:"Check out this body property!"
)comments
(example value:["First!", "Great post", "Hire this author now!"]
)
Create a
Dino
component insidesrc/Dino.js
Render your
App
component with the information from yourDino
component and pass in thedino
object as props values to theDino
component. For now, only display one of the comments,comments[0]
. You decide how you want to display thetitle
,author
,body
, andcomment
, orTake a screenshot and post in
Slack
.The
Solution
section below as inspiration.Optional: adjust the CSS of your index file body to align your text to the center of the document.
Solution
Here's what the solution might look like:
Going forward
Hang onto this code - we'll make some improvements to it so we can see all of the comments!
Last updated