ReactTraining / react-media

CSS media queries for React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react 16 Portals + iframes

raycohen opened this issue · comments

using react 16 portals, we are rendering part of our component tree into an iframe. We ran into the issue where the Media components in that part of the tree are referencing the parent window when we want it to reference the iframe.

Would you accept a PR to allow specifying the window object to be used (as an optional prop) for the matchMedia call, in our case sometimes an iframe's contentWindow?

Mmm, yes, that sounds like a good idea.

Can we make it automatic? For example, auto-detect if we are in an iframe and use that? I can't think of any situation where you'd render a <Media> in an iframe and want the media query registered on its parent window.

Related PR #78

Fixed in #78