class MyComponent extends React.Component {
constructor() {
super();
this.domRef = React.createRef();
this.state = {
domEl: null,
};
}
componentDidMount() {
this.setState({ domEl: this.domRef.current.tagName });
}
render() {
return (
<>
<RootRef rootRef={this.domRef}>
<Typography variant="h3" gutterBottom>
Reference attached here
</Typography>
</RootRef>
{`Referenced dom node: ${this.state.domEl}`}
</>
);
}
}