8bitzz / blogs

0 stars 0 forks source link

ReactJS Lifecycle Methods #1

Open 8bitzz opened 3 years ago

8bitzz commented 3 years ago

What is Component's LifeCycle

Reference: LifeCycle

This diagram of a React component's lifecycle offers a general overview of the concept. Lifecycle Methods

Mounting

The constructor is only called when an instance of the component is created and inserted in the DOM. The component gets instantiated. That process is called mounting of the component.

constructor(props)

render()

componentDidMount()

Updating

What about the update lifecycle of a component that happens when the state or the props change?

render()

componentDidUpdate(prevProps, prevState)

Unmounting

componentWillUnmount()