React
  • Introduction
  • Getting Started
    • Introduction
    • Before you get started
  • 1. Fundamentals
    • Introduction
    • Rendering
      • JSX
      • Exercise
      • Solution
    • Components
      • Stateless
        • Exercise
        • Solution
      • Stateful
        • Exercise
        • Solution
      • Styling
        • Exercise
        • Solution
        • Using CSS Modules
    • Folder Architecture
  • 2. Intermediate
    • Lifecycle methods
    • Controlled and Uncontrolled components
    • Anti-patterns
    • Refs and the DOM
    • Lifting State Up
  • 3. Advanced Topics
    • Conventions
    • Reconciliation
    • Performance Optimizations
      • Avoiding Reconciliation
      • PureComponent
      • Avoiding inline lambdas
      • Development vs Production build
    • Context
  • 4. Advanced Patterns
    • Higher-order Components
    • Children as Function
    • Renderless Components
    • Portals
    • Error handling
  • Exercises
    • Introduction
    • 1. ProductList light
      • Step 1
      • Step 2
      • Step 3
      • Step 4
      • Extra
      • Solution
Powered by GitBook
On this page
  • Create the component
  • Render your Title component
  1. 1. Fundamentals
  2. Components
  3. Stateless

Exercise

PreviousStatelessNextSolution

Last updated 6 years ago

In this exercise, you have to create and render the Title component of the app.

s_9d770ebd1641d231a06d1d808f243a8b1d9c4424b7c00b112f83df7ba3151d4b_1496154046364_screen shot 2017-05-30 at 10 20 16 am

Create the component

Create a new file named Title.js and create a simple component that is just a function that returns a React element.

import React from 'react';

function Title() {
  return (
    <h1>😺 Emoji picker 🐶</h1>
  );
}

Note that you have to import React as <h1> will be transformed into React.createElement('h1')

Render your Title component

In your App.js, you can use your Title component by importing it and simply adding the JSX call in your render function:

import Title from './Title';
render() {
  return {
    <Title />
  }
}

See solution