# 📆 20220411

  1. 问题描述:在React开发中,遇到一个问题,在从a页面b页面的时候,出现警告错误(不影响使用,但强迫症者表示不能出现任何报错)。

  2. 原因:内存泄漏问题

  3. 解决:

//在a页面添加componentWillUnmount
  state = {
    isUnmount:false
  };
  componentDidMount() {
    if (!this.state.isUnmount) {
      this.handleSelectDate('',getCurDate());
    }
   
  }
  componentWillUnmount(){
    this.setState({
      isUnmount:true
    })
  }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15