const CustomTextInput = React.forwardRef((props, ref) => (
));class AutoFocusTextInput extends React.Component {
constructor(props) {
super(props);
this.textInput = React.createRef();
}
componentDidMount() { // accessing method of grandchild component directly
this.textInput.current.focus();
}
render() {
return ();
}}ReactDOM.render(, document.querySelector('div'));