I have this specific need to listen to a custom event in the browser and from there, I have a button that will open a popup window. I\'m currently using React Portal to open
The issue is: a new div
is created on every render, just create the div
outside render
function and it should work as expected,
const containerEl = document.createElement('div')
const PopupWindowWithHooks = props => {
let externalWindow = null
... rest of your code ...
https://codesandbox.io/s/q9k8q903z6