This video is available to students only
- The newline Guide to Modernizing an Enterprise React App
- Create Custom Hooks for the App
Simplify Complex Components with the useProducts Hook
Custom hooks are good for more than just drying up duplicated code; they also help simplify our components.
This page is a preview of The newline Guide to Modernizing an Enterprise React App
- The useProducts Hook will make complicated components easier to follow
- We do a lot of product-related data transformations in the <ProductList> component
- In <ProductList>, we fetch products and make dynamic filters based on their brand names
- Create a new useProducts.js file
- Add the product, filtersByBrand and error states to the hook
- Copy the useEffect and bring its code to the hook
Contents