componentWillMount() componentDidMount() componentWillReceiveProps() shouldComponentUpdate() componentWillUpdate() componentDidUpdate() componentWillUnmount()接下来的几节课将介绍这些生命周期方法的一些基本用例。 render()方法之前调用componentWillMount()方法。在componentWillMount()中将某些内容记录到控制台 - 您可能希望打开浏览器控制台以查看输出。 MyComponent应该呈现div元素。
testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(MyComponent)); return mockedComponent.find('div').length === 1; })());
- text: 应该在componentWillMount调用console.log 。
testString: assert((function() { const lifecycle = React.createElement(MyComponent).type.prototype.componentWillMount.toString().replace(/ /g,''); return lifecycle.includes('console.log('); })());
```