BeginnerCoder

Lesson 1 — Your first component

Components return UI

A component is a JavaScript function whose name starts with a capital letter and that returns JSX — HTML-like markup written inside JavaScript. A component must return one parent element; to group several without an extra box, wrap them in a fragment: <>…</>. The preview on the right redraws every time you edit.

function Card() {
  return (
    <>
      <h2>Title</h2>
      <p>Some text</p>
    </>
  );
}

Why it matters: everything in a React app — buttons, pages, the whole site — is built from components like this.

Want it another way?
Task

Add a paragraph under the heading. The preview should show "Hello, React" and below it "I am learning React".

Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.