Skip to content

Commit

Permalink
Merge pull request #1792 from DouyinFE/fix_react18StrictMode
Browse files Browse the repository at this point in the history
fix: fix portal not popup when in react18 strict mode
  • Loading branch information
DaiQiangReal authored Sep 11, 2023
2 parents c8e5ca7 + dc6f3f7 commit 0ff761f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/semi-ui/_portal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Portal extends PureComponent<PortalProps, PortalState> {
context: ContextValue;
constructor(props: PortalProps, context: ContextValue) {
super(props);
this.state = {
this.state = {
container: this.initContainer(context, true)
};
}
Expand All @@ -55,10 +55,7 @@ class Portal extends PureComponent<PortalProps, PortalState> {
initContainer = (context: ContextValue, catchError = false) => {
try {
let container: HTMLElement | undefined = undefined;
if (!this.el) {
this.el = document.createElement('div');
}
if (!this.state?.container) {
if (!this.el || !this.state?.container || !Array.from(this.state.container.childNodes).includes(this.el)) {
this.el = document.createElement('div');
const getContainer = this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
const portalContainer = getContainer();
Expand Down

0 comments on commit 0ff761f

Please sign in to comment.