Skip to content

Instantly share code, notes, and snippets.

@psychicbologna
Created September 5, 2019 07:49
Show Gist options
  • Save psychicbologna/05285515412d5e57aa2c9d2f8d00f6ae to your computer and use it in GitHub Desktop.
Save psychicbologna/05285515412d5e57aa2c9d2f8d00f6ae to your computer and use it in GitHub Desktop.
https://courses.thinkful.com/ei-react-v1/checkpoint/10#technical-details
Components created as classes have more features, such as life-cycle methods.
Each component class has several “lifecycle methods” that you can override on the class. These methods allow us to add behavior when a component is created, mounted, updated or removed.
The only required method is render. The other methods are optional.
This is an incomplete list of the methods:
constructor = The component is created. E.g. <Component />
render = The component is reacting to being created or updated
This will happen at least once
If the components props change, render can happen again
If the components state changes, the render can also happen again
update the DOM = The component is added or changed in the DOM
If the component's render function returns something, it'll be mounted
If the result of render function is different to what's on the page, it'll be updated
componentDidMount = The component has been added to the DOM
componentWillUnmount = The component is about to be removed from the DOM
When the parent component's render doesn't render this component anymore, the component will be removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment