在这里,无需使用setTimeout。有一些组件的生命周期方法,其中的方法
componentDidMount在渲染之后被调用。因此,您可以在该方法中获取对div的引用。
var TodoItem = React.createClass({ ... componentDidMount: function () { if(this.myDiv) { this.myDiv.style.backgroundColor = "red"; } } render:function(){ return( <div className='name' ref = {c => this.myDiv = c}></div> );});


