fix #2688 避免对已经unmount的组件进行操作 (#2720)

This commit is contained in:
ddcat1115 2016-08-15 17:49:41 +08:00 committed by 偏右
parent 3128b15ea5
commit 2c76b19a1a

View File

@ -11,7 +11,6 @@ export default function confirm(config) {
let div = document.createElement('div');
document.body.appendChild(div);
let d;
props.iconType = props.iconType || 'question-circle';
let width = props.width || 416;
@ -29,11 +28,10 @@ export default function confirm(config) {
props.cancelText = props.cancelText || runtimeLocale.cancelText;
function close() {
d.setState({
visible: false,
});
ReactDOM.unmountComponentAtNode(div);
div.parentNode.removeChild(div);
const unmountResult = ReactDOM.unmountComponentAtNode(div);
if (unmountResult) {
div.parentNode.removeChild(div);
}
}
function onCancel() {
@ -126,9 +124,7 @@ export default function confirm(config) {
>
<div style={{ zoom: 1, overflow: 'hidden' }}>{body} {footer}</div>
</Dialog>
, div, function () {
d = this;
});
, div);
return {
destroy: close,