Component Life Cycle
- Every component in React has various phases.
- Every phase resembles a hook or method that handles specific
functionality.
- Component have several phases from loading to destroying.
- The component phases are classified into 3
o Mounting
o Updating
o Unmounting
- The three component phases are handled by 3 life cycle
methods called Hooks
o componentDidMount()
o componentDidUpdate()
o componentWillUnmount()
Mounting: When a component is initialized
- constructor
- getDefaultProps
- getInitialState
- componentWillMount()
- render
- componentDidMount()
Updating: When a component has state changed [Change
Detection]
- shouldComponentUpdate() [identifies the changes] – value
before change - old value
- componentWillUpdate()
- render
- componentDidUpdate() – value after change - new value
Unmounting: When a component is unmounting [Cleaning Up /
Destroying]
- destruct the objects
- destroy the memory allocated for object
- componentWillunmount()
Component Life Cycle in React.docx

Component Life Cycle in React.docx

  • 1.
    Component Life Cycle -Every component in React has various phases. - Every phase resembles a hook or method that handles specific functionality. - Component have several phases from loading to destroying. - The component phases are classified into 3 o Mounting o Updating o Unmounting - The three component phases are handled by 3 life cycle methods called Hooks o componentDidMount() o componentDidUpdate() o componentWillUnmount()
  • 2.
    Mounting: When acomponent is initialized - constructor - getDefaultProps - getInitialState - componentWillMount() - render - componentDidMount() Updating: When a component has state changed [Change Detection] - shouldComponentUpdate() [identifies the changes] – value before change - old value - componentWillUpdate() - render - componentDidUpdate() – value after change - new value Unmounting: When a component is unmounting [Cleaning Up / Destroying] - destruct the objects - destroy the memory allocated for object - componentWillunmount()