Lesson 7 of 3023%

(Progress persistence is disabled until Phase 9)

React
Beginner

Components and Composition

Building complex UIs from small building blocks.

The true power of React is composition. You can build large applications by combining smaller, reusable components.

Let’s build a profile card:

function Avatar() {
  return <img className="avatar" src="avatar.jpg" alt="User" />;
}

function UserInfo() {
  return (
    <div>
      <h2>Jane Doe</h2>
      <p>Software Engineer</p>
    </div>
  );
}

// Composing them together
function ProfileCard() {
  return (
    <div className="card">
      <Avatar />
      <UserInfo />
    </div>
  );
}
Try It Yourself

Lesson Progress

Take QuizBuild a React Project