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
  1. 1. Fundamentals
  2. Rendering

Exercise

PreviousJSXNextSolution

Last updated 6 years ago

To practice using JSX and embedding expressions with JSX, let's try creating a notification bell element that can transition between three different states:

badges
  1. When there are no notifications, we want to only display the notification icon.

  2. If there are less than 99 notifications, we'll want to display the icon and notifications badge.

  3. If there are more than 99 notifications, we'll want to truncate the number of notifications shown on the badge and only display 99+, and we'll want to add an has-fire class to the notification badge to display the flames.

See the solution