Reading Class 23 - martinbalke-401-adavanced-js/seattle-javascript-401n14 GitHub Wiki

Custom React Hooks

Custom react hooks allow you to create your own hooks for use in the react API. These can be very powerful for a few reasons. They allow you to DRY out your code. If you are using a useEffect to set the document title in four different components, making your own custom react hook to do that will be 1/4th of the code. Another thing that is very powerful about writing your own custom react hooks is that you are able to make the parameters more flexible. If you want to write and read to your mongodb you can write a hook that accepts a table as a parameter allowing you to use that function to write to multiple different tables just by changing the one variable.