October 2019
Intermediate to advanced
426 pages
11h 49m
English
The useResource Hook already handles the state for the result of our request, so we do not need an additional useState Hook to store the state. If we already have an existing Reducer Hook, however, we can use it in combination with the useResource Hook.
We are now going to implement the useResource Hook in combination with a Reducer Hook in our app:
import { useResource } from 'react-request-hook'
const [ posts, getPosts ] = useResource(() => ({ url: '/posts', method: 'get' }))
Read now
Unlock full access