CodeBlanks Logo Icon CodeBlanks

Summary - JSX basics

Combine JSX expressions, attributes and styles to write a welcome card.

Summary - JSX basics

In this group you learned what JSX is, how to embed JavaScript expressions in curly braces, and how attributes are written in JSX. Now it's time to put it together.

The flow is: define a function, return JSX inside it, put dynamic values in curly braces, and write camelCase attributes such as className and htmlFor. Finally, export the component with export default.

In the next step you'll combine these in a single component.

Practice Welcome card

Complete the skeleton. Write a component called Welcome that returns <section className="welcome"> with <h1>Hello</h1> and <p>Welcome to React</p> inside. Don't forget to export.

Starter code

App.jsx
// Write the Welcome component here

Sample solution

App.jsx
function Welcome() {
  return (
    <section className="welcome">
      <h1>Hello</h1>
      <p>Welcome to React</p>
    </section>
  );
}

export default Welcome;

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What goes inside curly braces?

  • An HTML tag
  • A CSS rule
  • A comment
  • A JavaScript expression Correct answer

Explanation: Curly braces hold a JavaScript expression.

2 Match the flow steps

Term Meaning
function Define
return Return
className Class
export default Export

All lessons in Beginner