Articles → REACT.JS → React Lifecycle
React Lifecycle
Phases Of The Component
- Mounting
- Updating
- Unmounting
Mounting
- 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
Updating
- getDerivedStateFromProps()
- shouldComponentUpdate() → Checks if the component output is affected by the change in the state or props
- render()
- getSnapshotBeforeUpdate() → This method is called before the update. Calling componentDidUpdate method is also required along with getSnapshotBeforeUpdate
- componentDidUpdate() → This method is called when a component is updated
Unmounting
- componentWillUnmount() → This method is called when the component is about to be removed from the DOM