摘要: 组件的生命周期 React中组件也有生命周期,也就是说也有很多钩子函数供我们使用, 组件的生命周期,我们会分为四个阶段,初始化、运行中、销毁、错误处理(16.3之后) 初始化 在组件初始化阶段会执行 constructor static getDerivedStateFromProps() comp 阅读全文
posted @ 2021-03-01 15:34 追求极致 阅读(2213) 评论(0) 推荐(0) 编辑
摘要: 因为最近在做一个逻辑较为复杂的需求,在封装组件时经常遇到父组件props更新来触发子组件的state这种情景。在使用componentWillReceiveProps时,发现React官网已经把componentWillReceiveProps重名为UNSAFE_componentWillRecei 阅读全文
posted @ 2021-03-01 13:34 追求极致 阅读(1192) 评论(0) 推荐(0) 编辑