# day002 **Repository Path**: yang-wanting/day002 ## Basic Information - **Project Name**: day002 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-10-27 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ###### day02总结: 今天讲了react里的生命周期和合并异步函数的知识,利用了这些知识写了一个TODOLIST的案例,一下就是这些知识的大概: 三种状态 1. 初始化 2.更新 3.销毁; 有状态组件从挂在到卸载经历一下生命周期: constructor() { super() // 必须在定义在内部state之前 } // super指代父类实例,调用super继承父类的this对象 UNSAFE_componentWillMount(){} //组件即将加载componentWillMount在16.3.0被弃用但目前前依然可用,以下UNSAFE_开头的均同理 render(){} //组件被渲染 componentDidMount(){} //组件已加载 UNSAFE_componentWillReceiveProps(nextProps){} // 组件将要从父组件获得props shouldComponentUpdate(nextProps, nextState){} // 是否确认重新渲染组件 render() {} // 重新渲染组件 UNSAFE_componentWillUpdate(){} // 组件将要更新 componentDidUpdate(){} // 组价被更新 componentWillUnmount(){} // 组件将要卸载 ![](C:\Users\DeLL\Desktop\3.png) 由于更新队列为异步的,因此当多次连续调用 setState 时,组件的状态会被 同步合并,待全部完成后,才会进入更新队列的冲洗并最终只执行一次组件更新