Skip to content

Commit fd694b6

Browse files
authored
Revert "fix: prevent from creating multi portals (#292)" (#293)
This reverts commit 03d0ad0.
1 parent 82d198e commit fd694b6

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/index.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ export function generateTrigger(
156156

157157
triggerRef = React.createRef<React.ReactInstance>();
158158

159-
// ensure `getContainer` will be called only once
160-
portalContainer?: HTMLElement;
161-
162159
attachId?: number;
163160

164161
clickOutsideHandler: CommonEventHandler;
@@ -861,18 +858,10 @@ export function generateTrigger(
861858
let portal: React.ReactElement;
862859
// prevent unmounting after it's rendered
863860
if (popupVisible || this.popupRef.current || forceRender) {
864-
if (!this.portalContainer) {
865-
// In React.StrictMode component will call render multiple time in first mount.
866-
// When you want to refactor with FC, useRef will also init multiple time and
867-
// point to different useRef instance which will create multiple element
868-
// (This multiple render will not trigger effect so you can not clean up this
869-
// in effect). But this is safe with class component since it always point to same class instance.
870-
this.portalContainer = this.getContainer();
871-
}
872861
portal = (
873862
<PortalComponent
874863
key="portal"
875-
getContainer={() => this.portalContainer}
864+
getContainer={this.getContainer}
876865
didUpdate={this.handlePortalUpdate}
877866
>
878867
{this.getComponent()}

0 commit comments

Comments
 (0)