Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentWillUnmount() {
if (typeof window === 'undefined') return;
getWindow().clearTimeout(this.scrollTimeout);
}
componentDidMount() {
if (!this.dialogEl || typeof window === 'undefined') return;
this.scrollTimeout = getWindow().setTimeout(() => {
const offsetParent = this.dialogEl.offsetParent;
if (offsetParent.tagName === 'BODY' || offsetParent.tagName === 'HTML') {
return;
}
offsetParent.scrollTop = 0;
}, 0);
}