A higher-order component (HOC) is a functional component that takes in a component as a parameter and returns an enhanced version of that component. That may not make a lot of sense, so we're going to go through an example in this section. Our example creates a HOC called withLoader that can be applied to any component in order to add a loading spinner when the component is busy. We are going to use this in our React shop (that we worked on in the last section) in the product page whilst data is being fetched. It will look like the following when we have finished:
Higher-order components
Adding asynchronous data fetching
At the moment, the data fetching in our shop is instantaneous because all the data is local. So,...