mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Remove unnecessary spaces from useCallback.md (#8006)
This commit is contained in:
@@ -52,7 +52,7 @@ export default function ProductPage({ productId, referrer, theme }) {
|
||||
|
||||
On the initial render, `useCallback` returns the `fn` function you have passed.
|
||||
|
||||
During subsequent renders, it will either return an already stored `fn` function from the last render (if the dependencies haven't changed), or return the `fn` function you have passed during this render.
|
||||
During subsequent renders, it will either return an already stored `fn` function from the last render (if the dependencies haven't changed), or return the `fn` function you have passed during this render.
|
||||
|
||||
#### Caveats {/*caveats*/}
|
||||
|
||||
@@ -224,7 +224,7 @@ function useCallback(fn, dependencies) {
|
||||
|
||||
If your app is like this site, and most interactions are coarse (like replacing a page or an entire section), memoization is usually unnecessary. On the other hand, if your app is more like a drawing editor, and most interactions are granular (like moving shapes), then you might find memoization very helpful.
|
||||
|
||||
Caching a function with `useCallback` is only valuable in a few cases:
|
||||
Caching a function with `useCallback` is only valuable in a few cases:
|
||||
|
||||
- You pass it as a prop to a component wrapped in [`memo`.](/reference/react/memo) You want to skip re-rendering if the value hasn't changed. Memoization lets your component re-render only if dependencies changed.
|
||||
- The function you're passing is later used as a dependency of some Hook. For example, another function wrapped in `useCallback` depends on it, or you depend on this function from [`useEffect.`](/reference/react/useEffect)
|
||||
|
||||
Reference in New Issue
Block a user