From cb5a61cdbfa5e72646cfb954056c6a4fde490a8c Mon Sep 17 00:00:00 2001 From: Riley Avron Date: Tue, 25 Jun 2019 17:15:19 -0700 Subject: [PATCH] Add missing function call to example (#2102) An example for useEffect omitted the actual invocation of the function in question. --- content/docs/hooks-faq.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/docs/hooks-faq.md b/content/docs/hooks-faq.md index 12e1db0b..a61e99e9 100644 --- a/content/docs/hooks-faq.md +++ b/content/docs/hooks-faq.md @@ -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]); ```