diff --git a/components/modal/index.jsx b/components/modal/index.jsx index 9aa58b1453..77ed230151 100644 --- a/components/modal/index.jsx +++ b/components/modal/index.jsx @@ -207,6 +207,8 @@ class Modal extends React.Component { if (props.ariaHideApp) { checkAppElementIsSet(); } + + this.selfRef = React.createRef(); } componentDidMount() { @@ -224,14 +226,13 @@ class Modal extends React.Component { // and manager.jsx are removed. They appear to have // been created in order to do modals in portals. if (!this.isUnmounting) { - const el = ReactDOM.findDOMNode(this); // eslint-disable-line react/no-find-dom-node if ( - el && - el.parentNode && - el.parentNode.getAttribute('data-slds-modal') + this.selfRef && + this.selfRef.parentNode && + this.selfRef.parentNode.getAttribute('data-slds-modal') ) { - ReactDOM.unmountComponentAtNode(el); - document.body.removeChild(el); + ReactDOM.unmountComponentAtNode(this.selfRef); + document.body.removeChild(this.selfRef); } } }