October 2019
Intermediate to advanced
426 pages
11h 49m
English
We repeat the same process for the posts state. Create a new src/hooks/usePostsState.js file with the following contents:
import { useContext } from 'react'import { StateContext } from '../contexts'export default function usePostsState () { const { state } = useContext(StateContext) return state.posts}
Similarly to the useTheme and useUserState Hooks, the usePostsState Hook makes our code more concise, easier to change later, and improves readability.
Read now
Unlock full access