rmariuzzo / react-new-window

🔲 Pop new windows in React, using `window.open`.
https://rmariuzzo.github.io/react-new-window/
MIT License
448 stars 110 forks source link

How do you get the "document" of the new window ? #150

Closed axelmy318 closed 1 year ago

axelmy318 commented 1 year ago

Hello, I've been trying to put a listener on the window size but it always get the main window. Does anyone knows how to access the "document" or "window" variable of the new window ? Even document.getElementById() doesn't work in a useLayoutEffect when trying to get a DOM element in that new page. Thanks :)

New window : image

NewWindowContent image

gnekoz commented 1 year ago

Hi, you should get the new window object as parameter in the onOpen callback

axelmy318 commented 1 year ago

Thanks. I ended up making my own package but I hope your answer can be useful to someone else