Skip to content

Commit d9d6d95

Browse files
authored
Merge pull request reactjs#216 from knpwrs/ref-did-mount
Explicitly note that ref callbacks are called before componentDidMount.
2 parents f5ab0b4 + 18097a2 commit d9d6d95

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

content/docs/refs-and-the-dom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CustomTextInput extends React.Component {
6666
}
6767
```
6868

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.
7070

7171
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}`.
7272

0 commit comments

Comments
 (0)