-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provide optional targetWindow
prop
#78
Conversation
targetWindow
prop. paired with @tonyjmnztargetWindow
prop
I'd prefer to not have a |
@mjackson the only way I can think of to auto-detect the iframe would be to wait until after the There are 2 problems with this - first, Do you have thoughts on that or other avenues we can explore? |
What about |
The problem we initially saw with that approach was that with our current iframe-rendering implementation (using react-frame-component at the moment) the |
Huh, interesting. Do you know how stuff gets passed to the iframe? Are you rendering a string and passing in HTML? |
The library we're using is using |
AFAIK the only reason you need to use In any case, it sounds like you (and probably others) may end up needing the |
modules/Media.js
Outdated
@@ -31,7 +30,7 @@ class Media extends React.Component { | |||
|
|||
componentWillMount() { | |||
let { query } = this.props; | |||
const { targetWindow } = this.props; | |||
const targetWindow = this.props.targetWindow || window; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still breaks server-side rendering because componentWillMount
fires on the server but window
is not defined.
modules/Media.js
Outdated
@@ -31,7 +30,7 @@ class Media extends React.Component { | |||
|
|||
componentWillMount() { | |||
let { query } = this.props; | |||
const { targetWindow } = this.props; | |||
const targetWindow = this.props.targetWindow || window; | |||
|
|||
if (typeof targetWindow !== "object") return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the line that checks to make sure we're actually in a browser. It should stay:
if (typeof window !== 'object') return;
and then get the targetWindow
prop afterwards.
Looks good. Thanks, guys! |
This was released in 1.8.0-rc.1. Please give it a shot and let me know if it works for you! npm install react-media@next |
worked like a charm, thanks for merging! |
We didn't realize that master had changed since the 1.6.1 release when we started this work.
We wrote tests but haven't tested this against live code because we ran into issues
yarn link
ing it to our project. Our create-react-app was complaining about the syntax in theesm
build artifact.Wanted to share and get your feedback. Maybe you know why we had issues with using the build?
paired with @tonyjmnz