Skip to content

Instantly share code, notes, and snippets.

@daniel-williams
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniel-williams/832114edfff779f6aa4f to your computer and use it in GitHub Desktop.
Save daniel-williams/832114edfff779f6aa4f to your computer and use it in GitHub Desktop.
React Component Template
var _debug = true;
var XXXXXX = React.createClass({
displayName: 'XXXXXX',
// Mixins
mixins: [],
// Props
propTypes: {
},
getDefaultProps: function() {
_debug ? console.log('XXXXXX => getDefaultProps | props:', this.props) : null;
return {
};
},
// State
getInitialState: function() {
_debug ? console.log('XXXXXX => getInitialState | state:', this.state) : null;
return {
};
},
// Mount
componentWillMount: function() {
_debug ? console.log('XXXXXX => componentWillMount | state:', this.state, ', props:', this.props) : null;
},
componentDidMount: function() {
_debug ? console.log('XXXXXX => componentDidMount | state:', this.state, ', props:', this.props) : null;
// React.findDOMNode(this)
},
componentWillUnmount: function() {
_debug ? console.log('XXXXXX => componentWillUnmount | state:', this.state, ', props:', this.props) : null;
},
// Updates
componentWillReceiveProps: function(nextProps) {
_debug ? console.log('SignIn => componentWillReceiveProps | props:', this.props, ', nextProps:', nextProps) : null;
},
//shouldComponentUpdate: function() {},
componentWillUpdate: function() {
_debug ? console.log('XXXXXX => componentWillUpdate | state:', this.state, ', props:', this.props) : null;
},
componentDidUpdate: function() {
_debug ? console.log('XXXXXX => componentDidUpdate | state:', this.state, ', props:', this.props) : null;
// DOM stuff here
},
// render
render: function() {
_debug ? console.log('XXXXXX => render | state:', this.state, ', props:', this.props) : null;
},
});
module.exports = XXXXXX;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment