Refs and the DOM: clarify when ref callbacks are invoked (#1069)

This commit is contained in:
Dmitry Minkovsky
2018-07-19 14:14:52 -04:00
committed by Alex Krolick
parent 48cbb02dd2
commit 7f1b367eb6

View File

@@ -251,7 +251,7 @@ class CustomTextInput extends React.Component {
}
```
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.
React will call the `ref` callback with the DOM element when the component mounts, and call it with `null` when it unmounts. Refs are guaranteed to be up-to-date before `componentDidMount` or `componentDidUpdate` fires.
You can pass callback refs between components like you can with object refs that were created with `React.createRef()`.