You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/reference/react/useRef.md
+1-74Lines changed: 1 addition & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -663,7 +663,7 @@ export default function ReactLogo() {
663
663
}
664
664
```
665
665
666
-
To avoid unnecessary reconnections wrap your ref callback function in [useCallback](/reference/react/useCallback). Make sure to add any dependancies to the dependency array so the ref callback called with updated props when necessary.
666
+
To avoid unnecessary reconnections wrap your ref callback function in [useCallback](/reference/react/useCallback). Make sure to add any dependancies to the `useCallback`dependency array. This will ensure the ref callback is called with updated props when necessary.
667
667
668
668
```js
669
669
exportdefaultfunctionReactLogo() {
@@ -675,79 +675,6 @@ export default function ReactLogo() {
675
675
}
676
676
```
677
677
678
-
<Sandpack>
679
-
680
-
```js
681
-
import { useState, useCallback } from"react";
682
-
683
-
functionWithoutCallback() {
684
-
const [count, setCount] =useState(0);
685
-
686
-
// 🚩 without useCallback, the callback changes every
0 commit comments