In this short practice, you will apply your existing knowledge to complete the
SingleArticle
component.
Click the Download Project
button at the bottom of this page to go to the
starter repo, then load the repo into CodeSandbox.
In src/components/SingleArticle/index.js, use the parameter given in the URL
to choose the correct article from the articles
array. (How can you access
the parameter?) Display the information for that article inside the JSX,
replacing the hard-coded information.
Choose one of the following options for passing the state into the
SingleArticle
component:
- Pass the articles from the
ArticleList
component to theSingleArticle
component - Use
useSelector
to load the articles directly from the reducer
When you've finished, you should be able to see the individual articles as you click on their respective titles in the "Article List".
Congratulations! In this practice you have applied your previous knowledge to
- Display information in JSX based on a URL parameter.