Reactjs React 0.13.3不调用ComponentDidMount

Reactjs React 0.13.3不调用ComponentDidMount,reactjs,Reactjs,我很难理解为什么在下面的代码中没有调用ComponentDidMount var React = require ('react'); class Sidebar extends React.Component { constructor(props) { super(props); this.state = { indexes: [ ] }; } ComponentDidMount () { console

我很难理解为什么在下面的代码中没有调用
ComponentDidMount

var React = require ('react');

class Sidebar extends React.Component {
      constructor(props) {
        super(props);
        this.state = { indexes: [ ] };
      }

      ComponentDidMount () {
        console.log('mounted');
      }

      render () {
        return (
          <div className="sidebar">
            <nav className="nav">
              <ul>
                {this.state.indexes.map((itm) => (
                  <li key={itm.id}><a href="#">{itm.name}</a></li>
                ))}
              </ul>
            </nav>
          </div>
        );
      }
    };

module.exports = Sidebar;
var React=require('React');
类侧栏扩展了React.Component{
建造师(道具){
超级(道具);
this.state={index:[]};
}
组件安装(){
console.log('mounted');
}
渲染(){
返回(
    {this.state.indexes.map((itm)=>(
  • ))}
); } }; module.exports=侧栏;
我有什么遗漏吗


谢谢

ComponentDidMount=>ComponentDidMount?区分大小写

ComponentDidMount=>ComponentDidMount?区分大小写

我现在觉得有点傻。花了很多时间在没有注意到大写字母“C”的情况下试图找出错误所在。但这有点可笑,因为对我来说,它也因为拼写错误而“坏了”。这个答案很好地提醒了我们,是的,拼写错误是目前为止这种方法不起作用的首要原因:)我现在觉得有点傻。花了很多时间在没有注意到大写字母“C”的情况下试图找出错误所在。但这有点可笑,因为对我来说,它也因为拼写错误而“坏了”。这个答案很好地提醒了我们,是的,拼写错误是目前为止这种方法不起作用的首要原因:)