You can use ReactDOM.findDOMNode. Although the documentation recommends using ref , let's see how this works:
findDOMNode ()
ReactDOM.findDOMNode(component)
DOM, DOM . DOM, DOM. ref DOM findDOMNode.
null false, findDOMNode null. , findDOMNode DOM, . React 16, , findDOMNode DOM, .
. FindDOMNode - , DOM. , . findDOMNode ( , DOM). , (, findDOMNode() render() , ), . findDOMNode .
ref, :
ref , , ref . , CustomTextInput , , :
class AutoFocusTextInput extends React.Component {
componentDidMount() {
this.textInput.focusTextInput();
}
render() {
return (
<CustomTextInput
ref={(input) => { this.textInput = input; }} />
);
}
}
, , CustomTextInput :
class CustomTextInput extends React.Component {
}