Last active
August 29, 2015 14:05
-
-
Save chochinlu/0a9419dfe927adb43e42 to your computer and use it in GitHub Desktop.
TodoList react component to demo react component lifecycle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
var React = require('react'); | |
var TodoList = React.createClass({ | |
getInitialState: function(){ | |
console.log('getInitialState'); | |
return null; | |
}, | |
componentWillMount: function(){ | |
console.log('componentWillMount'); | |
}, | |
componentDidMount: function(){ | |
console.log('componentDidMount'); | |
}, | |
componentWillReceiveProps: function(){ | |
console.log('componentWillReceiveProps'); | |
}, | |
shouldComponentUpdate: function(){ | |
console.log('shouldComponentUpdate'); | |
return true; | |
}, | |
componentWillUpdate: function(){ | |
console.log('componentWillUpdate'); | |
}, | |
render: function(){ | |
console.log('render'); | |
var createItem = function(itemText){ | |
return <li key={itemText}>{itemText}</li>; | |
}; | |
return <ul>{this.props.items.map(createItem)}</ul>; | |
}, | |
componentDidUpdate: function(){ | |
console.log('componentDidUpdate'); | |
}, | |
componentWillUnmount: function(){ | |
console.log('componentWillUnmount'); | |
} | |
}); | |
module.exports = TodoList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment