Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Functional Components | Introduction to React Fundamentals
React Mastery
course content

Conteúdo do Curso

React Mastery

React Mastery

1. Introduction to React Fundamentals
2. Styling in React Apps
3. React Hooks and Context
4. React in the Real World

bookChallenge: 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:

  1. Create a Card component as a reusable card template.
  2. 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.
  3. Use the Card component twice in the App 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:

  1. You can use the same Card component for both cards and control their content using props.
  2. 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.
  3. Similarly, create props for alt and description and provide the appropriate values.
  4. To use these props within the child component Card, access them using dot notation since props is an object.

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 10
some-alt