Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
Defer adding the container to the DOM until componentDidMount. In Nex…
Browse files Browse the repository at this point in the history
…tJS, if the reactStrictMode is true, appending the container in the constructor does not render the children (#338)
  • Loading branch information
shofman committed Jun 28, 2023
1 parent ddee254 commit 0670b5f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/consent-manager/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ export default class Dialog extends PureComponent<DialogProps, {}> {
this.titleId = nanoid()
this.container = document.createElement('div')
this.container.setAttribute('data-consent-manager-dialog', '')

document.body.appendChild(this.container)
}

render() {
Expand Down Expand Up @@ -198,7 +196,7 @@ export default class Dialog extends PureComponent<DialogProps, {}> {
input.focus()
}
}

document.body.appendChild(this.container)
document.body.addEventListener('keydown', this.handleEsc, false)
document.body.style.overflow = 'hidden'
innerRef(this.container)
Expand Down

0 comments on commit 0670b5f

Please sign in to comment.