to access the value of state by calling this.props
2020 version see https://zh-hant.reactjs.org/docs/react-component.html
| getInitialState()
| componentWillReceiveProps(props){
setState({object})
}
| shouldComponentUpdate()
| componentWillMount()
| componentWillUpdate()
| render()
| componentDidMount()
| componentDidUpdate()
* deprecated
| getDefaultProps
| this.props.__
| this.state.__
https://juejin.im/post/5ac493bc51882577b45f3cfb
var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm
React.creatClass()
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {};
this.method = this.method.bind(this);
}
componentDidMount() {
${this.state.count}
}
componentDidUpdate() {
${this.state.count}
}
method() {
this.setState(state => ({
count: state.count + 1,
}));
}
render() {
return (
<div>
<p> {this.state.count} </p>
<button onClick={method}>
Click me
</button>
</div>
);
}
}