- star 数
- 9
- watcher 数
- 14
- fork 数
- 7,900
- issue 数
- 28
- 最終更新
- 2024/09/20
Now that you've learned how to work with components in React, it's time to build something and put those skills to use! Your goal for this lab is to make a static site in React to practice building components, writing JSX, and passing down data as props.
We'll be creating a personal blog site, similar to Dan Abramov's Overreacted:
There is some starter code available in src/components/App.js. There is also
some data in data/blog.js that is being imported into App so you can pass it
down to the components that need it.
Have a look at the components below and draw out a component hierarchy so you can determine how to pass data down as props.
Make a Header component as a child of App. It should return:
<header> element with the following elements inside:
<h1> with the name of the blog, passed as a prop called nameMake an About component as a child of App. It should return:
<aside> element with the following elements inside:
<img> element, with the src set to an image passed as a prop called
image<img> element should use this placeholder image as a default value
for the prop if no prop is passed in: "https://via.placeholder.com/215"alt attribute of "blog
logo"<p> element, with the text for the blog passed in as a prop called
aboutMake an ArticleList component as a child of App. It should return:
<main> element with the following components inside:
Article components (one component for each of the posts
passed down as props to ArticleList)key attribute to each ArticleMake an Article component as a child of ArticleList. It should return:
<article> element, with the following elements inside:
<h3> element displaying the title of the article, passed as a prop
called title<small> element displaying the date of the article, passed as a prop
called date
<p> element displaying the preview of the article, passed as a prop
called previewYou'll notice in the original Overreacted site, there's a 'minutes to read' indicator next to each article.
If the article takes less than 30 minutes to read:
If the article takes 30 minutes or longer to read:
There aren't tests for this feature, so you'll have to rely on running the code in the browser to see if your implementation works!