Skip to content

Instantly share code, notes, and snippets.

@iamssen
Last active August 29, 2015 14:14
Show Gist options
  • Save iamssen/874f38793ea026cda314 to your computer and use it in GitHub Desktop.
Save iamssen/874f38793ea026cda314 to your computer and use it in GitHub Desktop.
//var Mixin = {
// mixinMethod: function () {
// console.log('mixinMethod()')
// }
//}
module.exports = React.createClass({
// -------------------------------------
// Mixin
// -------------------------------------
//mixins: [Mixin],
// -------------------------------------
// Static Members
// -------------------------------------
//statics: {
// staticValue: parseInt(Math.random() * 100),
// staticMethod: function () {
// console.log('${NAME}.staticMethod()')
// }
//},
//displayName: '${NAME}',
render: function () {
//console.log('${NAME}.render()', this._rootNodeID)
// ---------------------------------
// API
// ---------------------------------
// this.props
// this.state
// this.setState(object)
// this.isMounted()
return (
<div>
<h1>props</h1>
<ul>
<li>a : {this.props.propA}</li>
<li>b : {this.props.propB}</li>
<li>c : {this.props.propC}</li>
</ul>
<h1>state</h1>
<ul>
<li>a : {this.state.stateA}</li>
<li>b : {this.state.stateB}</li>
</ul>
</div>
)
},
// -------------------------------------
// Properties (Attributes)
// React.PropTypes.any
// React.PropTypes.array
// React.PropTypes.bool
// React.PropTypes.func
// React.PropTypes.number
// React.PropTypes.object
// React.PropTypes.string
// React.PropTypes.arrayOf(React.PropTypes.string)
// React.PropTypes.element // ReactElement
// React.PropTypes.instanceOf(Class) // javascript instanceOf
// React.PropTypes.node
// React.PropTypes.objectOf(React.PropTypes.number)
// React.PropTypes.oneOf(['value1', 'value2'])
// React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number])
// React.PropTypes.shape({color:React.PropTypes.string, fontSize:React.PropTypes.number})
// function(props, propName, componentName): Error|void
// -------------------------------------
propTypes: {
propA: React.PropTypes.string.isRequired,
propB: React.PropTypes.number,
propC: React.PropTypes.string,
propCallback: React.PropTypes.func
},
//getDefaultProps: function () {
// console.log('${NAME}.getDefaultProps()')
// return {
// propB: 'prop b value',
// propC: 'prop c value'
// }
//},
// -> should${NAME}Update() 로 이어짐
//componentWillReceiveProps: function (nextProps) {
// console.log('${NAME}.componentWillReceiveProps()')
// console.log(nextProps)
//},
// -------------------------------------
// States
// -------------------------------------
//getInitialState: function () {
// console.log('${NAME}.getInitialState()')
// return {
// stateA: 'state a value',
// stateB: 'state b value'
// }
//},
// -------------------------------------
// Life Cycle
// @add
// -> componentWillMount()
// -> render()
// -> componentDidMount()
//
// @remove
// -> componentWillUnmount()
// -------------------------------------
//componentWillMount: function () {
// console.log('${NAME}.componentWillMount()')
//},
//
//componentDidMount: function () {
// console.log('${NAME}.componentDidMount()')
//},
//
//componentWillUnmount: function () {
// console.log('${NAME}.componentWillUnmount()')
//},
// -------------------------------------
// Updating
// @update setState()
// -> should${NAME}Update()
// -> componentWillUpdate()
// -> render()
// -> componentDidUpdate()
// -------------------------------------
//should${NAME}Update: function (nextProps, nextState) {
// console.log('${NAME}.should${NAME}Update()', nextProps, nextState)
//
// return this.props.propA != nextProps.propA
// || this.props.propB != nextProps.propB
// || this.props.propC != nextProps.propC
// || this.state.stateA != nextState.stateA
// || this.state.stateB != nextState.stateB
//},
//
//componentWillUpdate: function (nextProps, nextState) {
// console.log('${NAME}.componentWillUpdate()', nextProps, nextState)
//},
//
//componentDidUpdate: function (prevProps, prevState) {
// console.log('${NAME}.componentDidUpdate()', prevProps, prevState)
//}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment