The whole idea behind custom hooks is just so that we can extract component logic into reusable functions. Often times as we build out React applications, we see ourselves writing almost the same exact codes in two or more different components.
Full article