ElemeFE / element-react

Element UI
https://elemefe.github.io/element-react/index
MIT License
2.83k stars 443 forks source link

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

Open lotsofone opened 4 years ago

lotsofone commented 4 years ago

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.渲染
`<Freetest/>`

### 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,然后控制台就会报警