生命周期函数指在某一时刻组件会自动的调用的函数
image.png
- 组件即将被挂载到页面之前自动执行
componentWillMount - 组件即将被挂载到页面之后自动执行
componentDidlMount - 组件被更新之前会自动执行,返回一个布尔值
shouldComponentUpdate - 组件被更新之前会自动执行,但在shouldComponentUpdate之后执行,如果shouldComponentUpdate返回false,将不会被执行,如果返回true,将会执行
componentWillUpdate - 组件被更新完成之后会自动执行
componentDidUpdate - 组件从父组件接收参数,
如果这个组件第一次存在于父组件中,将不会被执行
如果这个组件之前已经存在于父组件中,就会被执行
componentWillReceiveProps - 当组件从页面剔除的时候,会被执行
componentWillUnmount