import React, { Component } from 'react';
class App extends Component {
componentDidMount () {
console.log('4: componentDidMount');
}
componentWillMount () {
console.log('2: componentWillMount');
}
shouldComponentUpdate () {
console.log('a: shouldComponentUpdate');
return true;
}
componentWillUpdate () {
console.log('b: componentWillUpdate');
}
componentDidUpdate () {
console.log('d: componentDidUpdate');
}
constructor () {
super();
this.state = {
num : 1
}
console.log('1: constructor');
}
render() {
console.log('c: 3: render');
return (
<div>
{this.state.num }
<button onClick={ e=> { this.setState({ num : 99})}}>更新数据</button>
</div>
);
}
}
export default App;
网友评论