Sai Ram Kunala
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
2 additions and
2 deletions
-
content/docs/hooks-faq.md
|
|
@ -589,7 +589,7 @@ function ProductPage({ productId }) { |
|
|
|
const [product, setProduct] = useState(null); |
|
|
|
|
|
|
|
async function fetchProduct() { |
|
|
|
const response = await fetch('http://myapi/product' + productId); // Uses productId prop |
|
|
|
const response = await fetch('http://myapi/product/' + productId); // Uses productId prop |
|
|
|
const json = await response.json(); |
|
|
|
setProduct(json); |
|
|
|
} |
|
|
@ -610,7 +610,7 @@ function ProductPage({ productId }) { |
|
|
|
useEffect(() => { |
|
|
|
// By moving this function inside the effect, we can clearly see the values it uses. |
|
|
|
async function fetchProduct() { |
|
|
|
const response = await fetch('http://myapi/product' + productId); |
|
|
|
const response = await fetch('http://myapi/product/' + productId); |
|
|
|
const json = await response.json(); |
|
|
|
setProduct(json); |
|
|
|
} |
|
|
|