search and replace ```\n< with ```\n\n< to ensure there's an empty line before closing tags
		
			
				
	
	
	
		
			2.2 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			2.2 KiB
		
	
	
	
	
	
	
	
id, title, challengeType, isRequired, videoUrl, localeTitle
| id | title | challengeType | isRequired | videoUrl | localeTitle | 
|---|---|---|---|---|---|
| 5a24c314108439a4d403617c | Use the Lifecycle Method componentWillMount | 6 | false | 使用生命周期方法componentWillMount | 
Description
componentWillMount() componentDidMount() componentWillReceiveProps() shouldComponentUpdate() componentWillUpdate() componentDidUpdate() componentWillUnmount()接下来的几节课将介绍这些生命周期方法的一些基本用例。 Instructions
render()方法之前调用componentWillMount()方法。在componentWillMount()中将某些内容记录到控制台 - 您可能希望打开浏览器控制台以查看输出。 Tests
tests:
  - text: <code>MyComponent</code>应该呈现<code>div</code>元素。
    testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(MyComponent)); return mockedComponent.find('div').length === 1; })());
  - text: 应该在<code>componentWillMount</code>调用<code>console.log</code> 。
    testString: assert((function() { const lifecycle = React.createElement(MyComponent).type.prototype.componentWillMount.toString().replace(/ /g,''); return lifecycle.includes('console.log('); })());
Challenge Seed
class MyComponent extends React.Component {
  constructor(props) {
    super(props);
  }
  componentWillMount() {
    // change code below this line
    // change code above this line
  }
  render() {
    return <div />
  }
};
After Test
console.info('after the test');
Solution
// solution required
/section>