in the previous article "React source code parsing (1): component implementation and mounting , we described the implementation and mounting of React components. Now let's explore the life cycle of components. We already know that the lifecycle of the component will be triggered only after the mount process starts, and a js object of type ReactElement will be generated. By parsing the information contained in the component object, the corresponding HTML information is obtained, inserted into the specified DOM container, and the rendering of the view is finally completed. So how is the life cycle of the component triggered in this process? in fact, the study of the declaration cycle of components is a more in-depth study of the mounting process of components. Lifecycle of components at the end of the previous article, we know that the ReactDOM.render () method internally generates four different types of wrapper components through the factory method, depending on the parameters passed in: ReactEmptyComponent ReactTextComponent ReactDOMComponent ReactCompositeComponent when executing the mount process, the lifecycle is triggered by executing mountComponent methods within each encapsulated component, but it is clear that the lifecycle exists only in the React custom component, that is, ReactCompositeComponent . Because the other three components do not have a lifecycle, let's first analyze the relatively easy three internal components that do not exist lifecycle. 1.ReactEmptyComponent is created by the ReactEmptyComponent.create () method, which finally calls the ReactDOMEmptyComponent method. Take a look at the source code: because the component is empty, almost all parameters are set to null and have nothing to do with…