Browse Source

fix(docs): small typos (#5787)

main
Pascal Fong Kye 2 years ago
committed by GitHub
parent
commit
8a12d3352d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/content/learn/manipulating-the-dom-with-refs.md
  2. 2
      src/content/learn/synchronizing-with-effects.md

2
src/content/learn/manipulating-the-dom-with-refs.md

@ -84,7 +84,7 @@ While DOM manipulation is the most common use case for refs, the `useRef` Hook c
### Example: Scrolling to an element {/*example-scrolling-to-an-element*/}
You can have more than a single ref in a component. In this example, there is a carousel of three images. Each button centers an image by calling the browser [`scrollIntoView()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) method the corresponding DOM node:
You can have more than a single ref in a component. In this example, there is a carousel of three images. Each button centers an image by calling the browser [`scrollIntoView()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) method on the corresponding DOM node:
<Sandpack>

2
src/content/learn/synchronizing-with-effects.md

@ -678,7 +678,7 @@ useEffect(() => {
}, [userId]);
```
You can't "undo" a network request that already happened, but your cleanup function should ensure that the fetch that's _not relevant anymore_ does not keep affecting your application. If the `userId` changes from `'Alice'` to `'Bob'`, cleanup ensures that the `'Alice'` response is ignored if even it arrives after `'Bob'`.
You can't "undo" a network request that already happened, but your cleanup function should ensure that the fetch that's _not relevant anymore_ does not keep affecting your application. If the `userId` changes from `'Alice'` to `'Bob'`, cleanup ensures that the `'Alice'` response is ignored even if it arrives after `'Bob'`.
**In development, you will see two fetches in the Network tab.** There is nothing wrong with that. With the approach above, the first Effect will immediately get cleaned up so its copy of the `ignore` variable will be set to `true`. So even though there is an extra request, it won't affect the state thanks to the `if (!ignore)` check.

Loading…
Cancel
Save