Update hook descriptions

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-11-16 14:17:53 +02:00
parent 9e9e7443c2
commit eeccde742b
13 changed files with 121 additions and 96 deletions

View File

@ -3,11 +3,11 @@ title: useFetch
tags: hooks,effect,state,intermediate
---
A hook that implements `fetch` in a declarative manner.
Implements `fetch` in a declarative manner.
- Create a custom hook that takes a `url` and `options`.
- Use the `React.useState()` hook to initialize the `response` and `error` state variables.
- Use the `React.useEffect()` hook to anychronously call `fetch()` and update the state varaibles accordingly.
- Use the `useState()` hook to initialize the `response` and `error` state variables.
- Use the `useEffect()` hook to anychronously call `fetch()` and update the state variables accordingly.
- Return an object containting the `response` and `error` state variables.
```jsx