Add missing function call to example (#2102)

An example for useEffect omitted the actual invocation of the function in question.
This commit is contained in:
Riley Avron
2019-06-25 17:15:19 -07:00
committed by Alex Krolick
parent 39f30d4211
commit cb5a61cdbf

View File

@@ -610,7 +610,7 @@ 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() {
@@ -618,6 +618,8 @@ This also allows you to handle out-of-order responses with a local variable insi
const json = await response.json();
if (!ignore) setProduct(json);
}
fetchProduct();
return () => { ignore = true };
}, [productId]);
```