Course Content
React Mastery
React Mastery
1. Introduction to React Fundamentals
What is React?SPAs vs. MPAs in Web DevelopmentHow React Works with the Virtual DOMIntroducing JSX in ReactCreating Complex JSX Elements Rendering Elements in ReactChallenge: Rendering ElementReact ComponentProps in ReactChallenge: Functional ComponentsConditional RenderingChallenge: Conditional Rendering - Chat NotificationChallenge: Conditional Rendering - Bank AlertRendering a Data CollectionChallenge: Rendering a Data CollectionIntroduction to React Section Sum-Up
2. Styling in React Apps
Introduction to Styling in ReactInline StylesInline Styles in PracticeChallenge: Inline StylesStyling with the CSS FileStyling with the CSS File in PracticeChallenge: Styling with the CSS FileStyling with the CSS ModulesFile Folder Structure OrganizationChallenge: CSS ModulesStyling in React Section Sum-Up
3. React Hooks and Context
Introduction: React Hooks and ContextuseState HookChallenge: Toggling VisibilityuseRef HookChallenge: Creating a Form ComponentuseEffect HookChallenge: Fetching and Displaying DatauseMemo HookChallenge: Car List FilteringContextContext in PracticeChallenge: World of Astronomy AppReact Hooks and Context Section Sum Up
Challenge: Functional Components
Task: Creating an Encyclopedia Source
In this task, you will create an encyclopedia source of two cards. Each card will display an image and a description. The goal is to practice creating functional components and passing data to child components using props.
Instructions:
- Create a
Card
component as a reusable card template. - In the
Card
component, accept the following props:link
: The URL of the image for the card;alt
: The alternative text for the image;description
: The description text for the card.
- Use the
Card
component twice in theApp
component to create two cards with the following content:
Card 1 (About the Sun):
- Image URL:
https://codefinity-content-media.s3.eu-west-1.amazonaws.com/code-1/react/introduction-to-react/sun.png
- Alternative text: Provide an appropriate description.
- Description: "The sun shone brightly, casting a warm glow across the tranquil beach."
Card 2 (About the Mountain):
- Image URL:
https://codefinity-content-media.s3.eu-west-1.amazonaws.com/code-1/react/introduction-to-react/mountain.png
- Alternative text: Provide an appropriate description.
- Description: "The hiker gazed in awe at the majestic mountain towering before them."
Ensure that both the Card
and App
components are appropriately modified to display the cards correctly.
Here's a starter code with placeholders for you to complete:
- You can use the same
Card
component for both cards and control their content using props. - To pass the URL as a prop, create a prop called
link
and provide the URL as its value. Enclose the value in double quotes since it's a string. - Similarly, create props for
alt
anddescription
and provide the appropriate values. - To use these props within the child component
Card
, access them using dot notation sinceprops
is an object.
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 10