<title>菜鸟教程 React 实例</title>
<script src="https://static.runcodex.com/assets/react/react-0.14.7/build/react.js"></script>
<script src="https://static.runcodex.com/assets/react/react-0.14.7/build/react-dom.js"></script>
<script src="https://static.runcodex.com/assets/react/browser.min.js"></script>
<script type="text/babel">
var Button = React.createClass({
getInitialState: function() {
setNewNumber: function() {
this.setState({data: this.state.data + 1})
<button onClick = {this.setNewNumber}>INCREMENT</button>
<Content myNumber = {this.state.data}></Content>
var Content = React.createClass({
componentWillMount:function() {
console.log('Component WILL MOUNT!')
componentDidMount:function() {
console.log('Component DID MOUNT!')
componentWillReceiveProps:function(newProps) {
console.log('Component WILL RECIEVE PROPS!')
shouldComponentUpdate:function(newProps, newState) {
componentWillUpdate:function(nextProps, nextState) {
console.log('Component WILL UPDATE!');
componentDidUpdate:function(prevProps, prevState) {
console.log('Component DID UPDATE!')
componentWillUnmount:function() {
console.log('Component WILL UNMOUNT!')
<h3>{this.props.myNumber}</h3>
document.getElementById('example')