Reusability is one of the compelling reasons for using components. They allow us to define chunks of markup and logic that can be reused by simply referencing them in other markup. This is an immensely powerful tool. So far, we’ve taken advantage of this on several occasions in previous chapters:
- TrailCard component
- FormSection component
- FormFieldSet component
- SuccessAlert and ErrorAlert components
NOTE
In this chapter, we’re going to take reusability to the next level. We’ll learn how to leverage templates and generics to make the ultimate reusable components. To give us a practical example, we’ll be enhancing the home page of Blazing Trails with a component that allows the user to toggle the layout between a grid and a table (figure 7.1).