Finally, we are going to adjust the CreatePost component by following these steps:
- Edit src/post/CreatePost.js and adjust the import statement to also import the useAPICreatePost Hook:
import { useUserState, useDispatch, useAPICreatePost } from '../hooks'
- Then, replace the current Resource Hook with the following:
const [ post, createPost ] = useAPICreatePost()
Now the CreatePost component uses our custom API Hook to create new posts via the API.