constructor(props)
initializing local state by assigning an object to this.state. Should not call setState() in the constructor(). Should assign this.state directly in constructor. In all other methods, need to use this.setState().
binding event handler methods to an instance.
getDerivedStateFromProps()
exists for rare use cases where the state depends on changing props over time
render()
the only required method in a class component. It should examine this.props and this.state and must return.
componentDidMount()
invoked after a component is mounted, good place to set up subscription. Don’t forget to unsubscribe in componentWillUnmount.
shouldComponentUpdate(nextProps, nextState)
after new props and setState(), if false, the component will not render. default true. rarely used.
getSnapshotBeforeUpdate()
get value(state) before the DOM is updated, not commonly used.
componentDidUpdate(prevProps, prevState, snapshot)
invoked after updating occurs. operate DOM after the component has been updated.
componentWillUnmount()
invoked before the component is unmounted and destroyed. clean up subscriptions. the component will not be re-rendered.