Articles → REACT.JS → React lifecycle
Phases of the component
- constructor() - This is the very first method called in the mounting phase. This method is used to initialize variable values.
- getDerivedStateFromProps() - This method is called just before the render method.
- render() - This method outputs the HTML on the browser.
- componentDidMount() - This method is called after the render method.
- shouldComponentUpdate() - Checks if the component output is affected by change in the state or props.
- getSnapshotBeforeUpdate() - This method is called before the update. Calling componentDidUpdate method is also required along with getSnapshotBeforeUpdate.
- componentWillUnmount() - This method is called when the component is about to be removed from the DOM.