Chapter 16. Component Composition

In this chapter, you will use component composition to build a reusable alert component. Component composition allows you to pass child components as props to another component, giving you flexible control over what renders. Component composition is a dynamic, powerful React tool that developers frequently use in component libraries.

You will use the alert component to display messages in two scenarios:

  • When the order submission is successful, you will display a thank-you message.

  • When the order submission fails, you will display an error message.

By the end of this chapter, your cart page will be complete (Figure 16.1, “Completed cart page”).

Figure 16.1. Completed cart page

Alert

Right now, you can use ...

Get React Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.