Creating a Single Orchestrating Component
Explore how to refactor multiple UI components into a single generic React component that handles searching, sorting, and filtering data. Understand the benefits and tradeoffs of consolidating functionality to create cleaner, more manageable code while maintaining flexibility.
Reviewing the effects of refactoring
Our SearchInput, Sorters, and Filters components have all been refactored to use the React render prop pattern. The code for the widgets and people data is far less complex than what we had previously in the App component. Here’s what the widgets data looks like now:
This is what the people data looks like:
One problem with this composition is that each functionality renders a separate list of the data. This is a disadvantage of the render prop pattern. It’s also immediately clear that all ...