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: content/docs/refs-and-the-dom.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ class CustomTextInput extends React.Component {
66
66
}
67
67
```
68
68
69
-
React will call the `ref` callback with the DOM element when the component mounts, and call it with `null` when it unmounts.
69
+
React will call the `ref` callback with the DOM element when the component mounts, and call it with `null` when it unmounts.`ref` callbacks are invoked before `componentDidMount` or `componentDidUpdate` lifecycle hooks.
70
70
71
71
Using the `ref` callback just to set a property on the class is a common pattern for accessing DOM elements. The preferred way is to set the property in the `ref` callback like in the above example. There is even a shorter way to write it: `ref={input => this.textInput = input}`.
0 commit comments