Skip to content

Commit

Permalink
Add missing function call to example (#2102)
Browse files Browse the repository at this point in the history
An example for useEffect omitted the actual invocation of the function in question.
  • Loading branch information
ravron authored and alexkrolick committed Jun 26, 2019
1 parent 39f30d4 commit cb5a61c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion content/docs/hooks-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,16 @@ function ProductPage({ productId }) {

This also allows you to handle out-of-order responses with a local variable inside the effect:

```js{2,6,8}
```js{2,6,10}
useEffect(() => {
let ignore = false;
async function fetchProduct() {
const response = await fetch('http://myapi/product/' + productId);
const json = await response.json();
if (!ignore) setProduct(json);
}
fetchProduct();
return () => { ignore = true };
}, [productId]);
```
Expand Down

0 comments on commit cb5a61c

Please sign in to comment.