Skip to content

Instantly share code, notes, and snippets.

@swapnilmishra
Last active February 19, 2017 09:03
Show Gist options
  • Save swapnilmishra/5b2e384f8baa863a1a393a219f3b3594 to your computer and use it in GitHub Desktop.
Save swapnilmishra/5b2e384f8baa863a1a393a219f3b3594 to your computer and use it in GitHub Desktop.

React lifecycle methods

constructor()
componentWillMount()
render()
componentDidMount()


componentWillReceiveProps(nextProps) - setState() can be called
shouldComponentUpdate(nextState,nextProps,context)
componentWillUpdate(nextProps,nextState)
render()
componentDidUpdate()

componentWillUnmount()

Basic ajax syntax

var request = new XMLHttpRequest()
request.open('POST','/url')
request.setRequestHeader('Content-type','application/json')
request.addEventListener('load', function(){
    if(request.status == 200){
        var data = JSON.parse(request.responseText)
    }
})
request.send()

splice,slice

  • string|array - slice(startIndex,endIndex)
  • string - substr(startIndex,length)
  • array - splice(startIndex,length,[replace])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment