Use React
time, our DOM
node 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:
- -
constructor
First, the constructor will trigger 01 - -
componentWillMount
Secondly trigger, indicates that the component will be mounted 02 - -
render
The data is then rendered 03 - -
componentDidMount
assembly loaded 04 (dom operation on here, the requested data is also placed here)
- -
-
- component data update when the trigger periodic function declaration:
- -
shouldComponentUpdate
First trigger, indicate whether you want to update the data, the method which must be true01 - -
componentWillUpdate
the time to update the data trigger 02 - -
render
Data Rendering 03 - -
componentDidUpdate
Data updated 04
- -
-
- you change the props of traditional values in the parent component inside when triggered:
- -
componentWillReceiveProps
operations are performed, at the time of the destruction of the component
- -
-
- when the component destroyed trigger:
- –
componentWillUnmount
- –