robbestad/react-iframe

onLoad properties on Component

Opened this issue · 3 comments

In the native iframe we have something like this:

<iframe src="/test.html" onLoad="alert(this.contentWindow.location);"></iframe> We may want to include that to the module.

I think it's a bug, because the onLoad attr is defined here (line 17):
https://github.com/svenanders/react-iframe/blob/master/src/types.d.ts
And here (line 42):
https://github.com/svenanders/react-iframe/blob/master/src/iframe.tsx
But it's really not working :(

The problem is that onLoad is defined as a void function

onLoad?: () => void,
So onLoad function doesn't returns the instance of the iframe (this) and returns a synthetic event instead, so you cannot acces to contentWindow

how do we access the location?