image.png
首先就会初始化默认的
props, 检验父级传递的 props 然后执行
constructor, 初始化 state componentWillMount: 组件即将挂载 render: 渲染 componentDidMount: 组件挂载完成 如果state 发生改变,
shouldComponentUpdate: 判断组件是否应该更改, 根据返回值去确定, 默认为true.如果返回false, 就执行完此函数, 回到之前的状态
父组件传递过来的props发生改变,
componentWillReceiveProps: 将会接收props, 这也会触发子组件的shouldComponentUpdate函数.
之后, 会触发componentWillUpdate, 这时候shouldComponentUpdate函数返回的是true, 然后重新render. 触发componentDidUpdate.
当组件被销毁的时候, 还有一个componentWillUnmount.
componentDidMount的时候, 发送ajax请求
shouldComponentUpdate: 可以用来优化性能, 如果state, props的值没有发生改变, 那就返回false, 阻止重新渲染
16.3 以后, componentWillMount``componentWillReceiveProps``componentWillUpdate被警告移除, 17.0之后正式移除



京公网安备 11010502036488号