We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e3e6260 + 7b4f99d commit 6ecaf4bCopy full SHA for 6ecaf4b
content/docs/hooks-faq.md
@@ -610,14 +610,16 @@ function ProductPage({ productId }) {
610
611
This also allows you to handle out-of-order responses with a local variable inside the effect:
612
613
-```js{2,6,8}
+```js{2,6,10}
614
useEffect(() => {
615
let ignore = false;
616
async function fetchProduct() {
617
const response = await fetch('http://myapi/product/' + productId);
618
const json = await response.json();
619
if (!ignore) setProduct(json);
620
}
621
+
622
+ fetchProduct();
623
return () => { ignore = true };
624
}, [productId]);
625
```
0 commit comments