ElemeFE / ElemeFE/element-react

Popover控制台报警Warning: Can't perform a React state update on an unmounted component

Open
#1,026 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.8k
Forks
435
PR merge metrics
No merged PRs in 30d

Description

### Description

动态渲染且触发条件为click的Popover,消失后再出现,再尝试触发时,控制台报警Warning: Can't perform a React state update on an unmounted component

### Reproduce Steps

1. 写一个简单的freetest页面
```
import React from 'react';
import {Popover, Tooltip} from 'element-react'
import 'element-theme-default'

class Freetest extends React.Component{
constructor(props){
super(props)
this.state = {sh : true}
setTimeout(()=>{this.setState({sh:false})}, 2000)
setTimeout(()=>{this.setState({sh:true})}, 4000)
}
render(){
return (


{this.state.sh?
// dawfawf
hello} trigger="click" openDelay={1000}>dafwawf
:null}

)
}
}

export {Freetest}
```
2.渲染
``

### Error Trace (if possible)

index.js:1375 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in Popover (at free_test.js:17)

### Solution

照着上面的代码,创建一个以click触发的消失又出现的popover元素,然后尝试用鼠标去打开Popover,然后控制台就会报警

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.