Skip to content

Commit 3a50721

Browse files
authored
fix conflict
1 parent 8febbd3 commit 3a50721

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

src/content/reference/react/useCallback.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ export default function ProductPage({ productId, referrer, theme }) {
5252
5353
在初次渲染时,`useCallback` 返回你已经传入的 `fn` 函数
5454
55-
<<<<<<< HEAD
5655
在之后的渲染中, 如果依赖没有改变,`useCallback` 返回上一次渲染中缓存的 `fn` 函数;否则返回这一次渲染传入的 `fn`
57-
=======
58-
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.
59-
>>>>>>> 790625fd221a079b06325df027d69f684b161b75
6056
6157
#### 注意 {/*caveats*/}
6258
@@ -228,11 +224,7 @@ function useCallback(fn, dependencies) {
228224
229225
如果你的应用程序与本网站类似,并且大多数交互都很粗糙(例如替换页面或整个部分),则通常不需要缓存。另一方面,如果你的应用更像是一个绘图编辑器,并且大多数交互都是精细的(如移动形状),那么你可能会发现缓存非常有用。
230226
231-
<<<<<<< HEAD
232227
使用 `useCallback` 缓存函数仅在少数情况下有意义:
233-
=======
234-
Caching a function with `useCallback` is only valuable in a few cases:
235-
>>>>>>> 790625fd221a079b06325df027d69f684b161b75
236228
237229
- 将其作为 props 传递给包装在 [`memo`] 中的组件。如果 props 未更改,则希望跳过重新渲染。缓存允许组件仅在依赖项更改时重新渲染。
238230
- 传递的函数可能作为某些 Hook 的依赖。比如,另一个包裹在 `useCallback` 中的函数依赖于它,或者依赖于 [`useEffect`](/reference/react/useEffect) 中的函数。

0 commit comments

Comments
 (0)