Skip to content

Instantly share code, notes, and snippets.

@pikender
Last active June 2, 2016 14:27
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 pikender/5b5d9c108cf0e611835f625d727a876d to your computer and use it in GitHub Desktop.
Save pikender/5b5d9c108cf0e611835f625d727a876d to your computer and use it in GitHub Desktop.
React References studied
@pikender
Copy link
Author

pikender commented Jun 2, 2016

  • componentDidMount, componentWillMount, getInitialState, componentWillReceiveProps, componentWillUnMount
  • this.props.location.query

axios.get()
axios.all(players.map(function(username){
return getUserInfo(username)
})).then(function(info) {
return info.map(function(user){
user.data
})
}).catch(function(err) {
// console.log(err)
})

bind(this) // sets the context of function

function puke(obj) {
return

{JSON.stringify(obj, null, ' ')}

}


// Implicit Binding => Left of dot at call time
// Explicit Binding => sayName.call(stacey, arg1, arg2) , sayName.apply(stacey, array), var new_function = sayName.bind(stacey, arg1, arg2)
// bind is same as call but returns function instead of invoking function
// new Binding => create a new object and assign to this, this = {}
// window Binding => set property on window => window.age = 35
// 'use strict' rejects all window bindings and raises errors


this.context.router.push({
pathName: '/results',
state: {
playersInfo: this.state.playersInfo
}
})

user.info.name && // conditional check for rendering element

PropTypes.shape // for irregular data

this.props.location.state.playersInfo

getDefaultProps: function() {
return {
text: 'Loading',
speed: 300
}
}


  • npm install --save react-addons-css-transition-group
  • npm install --save-dev css-loader style-loader

{React.cloneElement(this.props.children, {key: this.props.location.pathname})}

ReactCSSTransitionGroup needs a key so use React.cloneElement


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment