Commit ca49622c authored by Chunchi Che's avatar Chunchi Che

fix removeChild crash

parent 766e285b
Pipeline #23460 passed with stages
in 15 minutes and 34 seconds
...@@ -22,7 +22,10 @@ export const withPortalToBody = <P extends object>( ...@@ -22,7 +22,10 @@ export const withPortalToBody = <P extends object>(
return () => { return () => {
// 卸载组件并且移除容器 // 卸载组件并且移除容器
setTimeout(() => root.unmount()); setTimeout(() => root.unmount());
if (portalRoot.contains(newNode)) {
// 做个if判断,防止下面这行crash
portalRoot.removeChild(newNode); portalRoot.removeChild(newNode);
}
}; };
}, []); }, []);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment