React Vue's life cycle

Source: Internet
Author: User
React Component Life cycle

In this section we will discuss the life cycle of the React component.

The lifecycle of a component can be divided into three states: mounting: Inserted into the real Dom Updating: being re-rendered unmounting: Moved out of the real DOM

The life cycle methods are:

Componentwillmount is called before rendering, and is also on the service side of the client.

Componentdidmount : Called after the first render, only on the client. After that the component has generated the corresponding DOM structure, which can be accessed through This.getdomnode (). If you want to work with other JavaScript frameworks, you can call settimeout in this method, setinterval or send Ajax requests (to prevent a different operation from blocking the UI).

Componentwillreceiveprops is called when the component receives a new prop. This method is not called when the render is initialized.

shouldcomponentupdate Returns a Boolean value. Called when a component receives a new props or state. Not called at initialization time or when using ForceUpdate.
You can use it when you are sure that you do not need to update the component.

Componentwillupdate is called when the component receives a new props or state but has not yet been render. Will not be called at initialization time.

Componentdidupdate is called immediately after the component has finished updating. Will not be called at initialization time.

Componentwillunmount is called immediately when the component is removed from the DOM

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.