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