Another thing that we often do is access the global state. For example, some components need the user state and some need the posts state. To abstract this functionality, which will also make it easier to adjust the state structure later on, we can create custom Hooks to get certain parts of the state:
- useUserState: Gets the user part of the state object
- usePostsState: Gets the posts part of the state object