trigger
trigger copied to clipboard
in StrictMode, getContainer has side effect, duplicated div will be attached to Dom, please fix it.
let see the code bellow. In strict mode and dev environment, getContainer will be called twice, so double div will be attached to Dom, if we enable autoDestory, only one div will be removed after popup closed. That means every popup open and close will lead to one orphaned div, we may have multi divs in dom if we open and close popup muti times.
getContainer = () => {
const { getDocument } = this.props;
const popupContainer = getDocument(this.getRootDomNode()).createElement(
'div',
);
// Make sure default popup container will never cause scrollbar appearing
// https://github.com/react-component/trigger/issues/41
popupContainer.style.position = 'absolute';
popupContainer.style.top = '0';
popupContainer.style.left = '0';
popupContainer.style.width = '100%';
this.attachParent(popupContainer);
return popupContainer;
};
if (popupVisible || this.popupRef.current || forceRender) {
portal = (
<PortalComponent
key="portal"
getContainer={this.getContainer}
didUpdate={this.handlePortalUpdate}
>
{this.getComponent()}
</PortalComponent>
);
}
here give a screenshot.
have same problem,need author fix it...