(Xii) React lifecycle methods

Use Reacttime, our DOMnode mostly by dynamically rendering to achieve, so it is a key part of his a 生命周期函数的使用, the method or the code is written to the appropriate function in the life cycle, can greatly improve the level of our performance of the page.

-React lifecycle functions:

  • - before the components are loaded, the component loading King City, and update data components, assemblies destruction
    triggered some of the methods listed, which is a function of the life cycle of components

  • - function components loaded when the trigger:

    • - constructorFirst, the constructor will trigger 01
    • - componentWillMountSecondly trigger, indicates that the component will be mounted 02
    • - renderThe data is then rendered 03
    • - componentDidMountassembly loaded 04 (dom operation on here, the requested data is also placed here)
  • - component data update when the trigger periodic function declaration:

    • - shouldComponentUpdateFirst trigger, indicate whether you want to update the data, the method which must be true01
    • - componentWillUpdatethe time to update the data trigger 02
    • - renderData Rendering 03
    • - componentDidUpdateData updated 04
  • - you change the props of traditional values ​​in the parent component inside when triggered:

    • - componentWillReceivePropsoperations are performed, at the time of the destruction of the component
  • - when the component destroyed trigger:

    • componentWillUnmount
Published 106 original articles · won praise 10 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_32060101/article/details/101452799