Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jljsj33 committed Jun 8, 2020
1 parent 905cc63 commit a203afd
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/PortalWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class PortalWrapper extends React.Component {
constructor(props) {
super(props);
const { visible } = props;
openCount = visible ? openCount + 1 : openCount;
if (!windowIsUndefined && this.getParent() === document.body) {
openCount = visible ? openCount + 1 : openCount;
}
this.state = {
_self: this,
};
Expand All @@ -35,8 +37,10 @@ class PortalWrapper extends React.Component {

componentWillUnmount() {
const { visible } = this.props;
// 离开时不会 render, 导到离开时数值不变,改用 func 。。
openCount = visible && openCount ? openCount - 1 : openCount;
if (!windowIsUndefined && this.getParent() === document.body) {
// 离开时不会 render, 导到离开时数值不变,改用 func 。。
openCount = visible && openCount ? openCount - 1 : openCount;
}
this.removeCurrentContainer(visible);
}

Expand All @@ -47,7 +51,7 @@ class PortalWrapper extends React.Component {
visible: prevVisible,
getContainer: prevGetContainer,
} = prevProps;
if (visible !== prevVisible) {
if (visible !== prevVisible && !windowIsUndefined && this.getParent() === document.body) {
openCount = visible && !prevVisible ? openCount + 1 : openCount - 1;
}
const getContainerIsFunc =
Expand All @@ -67,6 +71,9 @@ class PortalWrapper extends React.Component {
}

getParent = () => {
if (windowIsUndefined) {
return null;
}
const { getContainer } = this.props;
if (getContainer) {
if (typeof getContainer === 'string') {
Expand Down

0 comments on commit a203afd

Please sign in to comment.