After getting a good grasp on the concept of Hooks by learning about the State and Effect Hooks, community Hooks, and the rules of Hooks, we are now going to build our own Hooks. We start by extracting custom Hooks from existing functionalities of our blog application. Usually, it makes the most sense to first write the component, and then later extract a custom Hook from it if we notice that we use similar code across multiple components. Doing so avoids prematurely defining custom Hooks and making our project unnecessarily complex.
We are going to extract the following Hooks in this section:
- A useTheme Hook
- The useUserState and usePostsState Hooks
- A useDispatch Hook
- API Hooks
- A useDebouncedUndo Hook