1import React from 'react';
2import M from 'materialize-css';
3....
4// ref can only be used on class components
5class SomeComponent extends Component {
6 // get a reference to the element after the component has mounted
7 componentDidMount(){
8 M.Sidenav.init(this.sidenav);
9 }
10
11 render(){
12 return (
13 <ul className={this.props.classes}
14 ref={ (sidenav) => {this.sidenav = sidenav} }
15 id={this.props.id}>
16 // menuItems
17 </ul>
18 )
19 }
20}