mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-24 04:33:10 +00:00
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:
committed by
Alex Krolick
parent
39f30d4211
commit
cb5a61cdbf
@@ -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]);
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user