4 Functional Components
This chapter covers
- Introducing functional components
- Comparing functional components to class-based components
- Choosing between the two types of component definitions
- Converting a class-based component to a functional component
React was based on class-based components for a long time in the early years, but an alternative came along for the simplest of components at some point. Functional components are a more succinct and, in some regards, simpler way of writing React components, and they now have the same feature set as their class-based cousins.
The term functional component isn’t meant as a contrast to a nonfunctional component—no one has any use for those. Rather, the functional part refers to the component definition ...
Get React Quickly, Second Edition 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.