卸载时只有一个生命周期 componentWillUnmount()
周期课执行的事件有:
1、取消无效请求
2、取消定时器
3、取消订阅
详细过程见代码
import React, {
Component } from 'react';
//组件生命周期---卸载时
// 卸载时只有一个生命周期 componentWillUnmount()
class Demo extends Component{
componentWillUnmount(){
console.log('点击按钮卸载Demo组件时,执行componentWillUnmount()周期,同时Demo组件被销毁'