0
0
Reactframework~30 mins

Functional components in React - Mini Project: Build & Apply

Choose your learning style9 modes available
Building a Simple React Functional Component
📖 Scenario: You are creating a small React app that shows a friendly greeting message on a webpage. This is like writing a simple note to welcome visitors.
🎯 Goal: Build a React functional component named Greeting that displays the text "Hello, welcome to React!" on the page.
📋 What You'll Learn
Create a functional component named Greeting
Use JSX to return a <div> containing the greeting text
Export the Greeting component as default
Use React 19+ functional component syntax with hooks (if needed)
💡 Why This Matters
🌍 Real World
React functional components are the building blocks of modern web apps. They let you create reusable pieces of UI that show information and respond to user actions.
💼 Career
Knowing how to write and compose functional components is essential for frontend developer roles working with React, a popular library used by many companies.
Progress0 / 4 steps
1
Set up the React component function
Create a functional component named Greeting using the syntax function Greeting() {}.
React
Need a hint?

Start by writing a function named Greeting with empty curly braces.

2
Add JSX to return a div with greeting text
Inside the Greeting function, add a return statement that returns a <div> containing the text Hello, welcome to React!.
React
Need a hint?

Use return <div>Your text</div>; inside the function.

3
Export the Greeting component as default
Add a line to export the Greeting component as the default export using export default Greeting;.
React
Need a hint?

Write export default Greeting; after the function.

4
Use the Greeting component in an app
Create a new functional component named App that returns the <Greeting /> component inside a <main> tag. Export App as default instead of Greeting.
React
Need a hint?

Write a new function App that returns <main><Greeting /></main> and export App as default.