Explain life Cycle of React JS Component ?

devquora
devquora

Posted On: Feb 22, 2018

 

React JS Component Lifecycle

Each component has several “lifecycle methods” that you can override to run code at particular times in the process. Methods prefixed with will are called right before something happens, and methods prefixed with did are called right after something happens.

Mounting

These methods are called when an instance of a component is being created and inserted into the DOM:

  • constructor()
  • componentWillMount()
  • render()
  • componentDidMount()

Updating

An update can be caused by changes to props or state. These methods are called when a component is being re-

rendered:

  • componentWillReceiveProps()
  • shouldComponentUpdate()
  • componentWillUpdate()
  • render()
  • componentDidUpdate()

Unmounting

This method is called when a component is being removed from the DOM:

  • componentWillUnmount()

Other APIs

Each component also provides some other APIs:

  • setState()
  • forceUpdate()

Class Properties

  • defaultProps
  • displayName

Instance Properties

  • props
  • state

Source: https://facebook.github.io/react/docs/react-component.html

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    React Js Interview Questions

    What is ReactJS ?

    React js is javascript based UI Library developed at Facebook, to create an interactive, stateful & reusable UI com..

    React Js Interview Questions

    List some advantages of ReactJS ?

    Advantages of React JsReact.js is extremely efficient: React.js creates its own virtual DOM where your components act..

    React Js Interview Questions

    What are Components in ReactJS ?

    React Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.Concep..