Skip to content

Instantly share code, notes, and snippets.

@HenriqueLimas
Last active April 10, 2017 11:46
Show Gist options
  • Select an option

  • Save HenriqueLimas/09acef93e5a913e025a460f84e3223b5 to your computer and use it in GitHub Desktop.

Select an option

Save HenriqueLimas/09acef93e5a913e025a460f84e3223b5 to your computer and use it in GitHub Desktop.

Code mode

Tool to transform your currently code to a new one that has braking change.

.createClass will be deprecated

React lifecycle methods

getInitialState/constructor one of the first methods called by React.

componentWillMount: before the DOM. Almost never used. That it call inside node js

componentDidMount: after put in the DOM. Its usefull because of the server side render. That one doesn't run on node env. The browser API is available here. (But try to always not use DOM inside React). Also ajax go inside here and jQuery or side event. D3 goes here too.

componentWillUnmount: after the elements remove of the DOM. Used to clean things.

getDefaultProps: useful for dependency injections.

shouldComponentUpdate: used to say if the components should or not update. Try to avoid this one.

Difference btw componentWillMount and didMount is ms.

ReactPerfTools, it shows how our components consuming times and see if we need to use shouldComponentUpdate.

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