class CustomTextInput extends React.Component { constructor(props) { super(props); this.textInputRef = React.createRef(); } focusTextInput() { // (1) accessing method of DOM node this.textInputRef.current.focus(); } render() { return (); }}class AutoFocusTextInput extends React.Component { constructor(props) { super(props); this.textInput = React.createRef(); } componentDidMount() { // (2) accessing method of child React component this.textInput.current.focusTextInput(); } render() { return (); }}ReactDOM.render(, document.querySelector('div'));