ElemeFE / ElemeFE/element-react

Popover 弹出框动态更新报Warning: Can't call setState

Open
#799 3 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

trigger="click"
动态渲染出的Popover 弹出框在更新数据后重新渲染,报Warning: Can't call setState (or forceUpdate) on an unmounted component.

### Reproduce Steps

1. 表格内带popover的按钮组件,trigger="click"
2. 表格数据更新,此时popover重新渲染
3. 点击带popover的按钮组件
4. 报错

### Error Trace (if possible)

https://github.com/eleme/element-react/blob/master/src/popover/Popover.jsx:31-70
componentDidMount 中绑定事件监听后但没有componentWillUnmount取消监听事件

### Solution

添加componentWillUnmount取消事件监听

### Additional Information

none

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.