Add `ref` so we can access the `<iframe>` used
See original GitHub issueWhen looking at the forwardRef
prop I initially expected it to work like React.forwardRef()
& the “Forwarding Refs” docs mentions - by being able to access all methods on a <iframe>
element (i.e. the HTMLIFrameElement
interface) so I could do things like forwardRef.current.contentWindow.location.reload()
for instance but was unable to.
It appears that the only methods on forwardRef.current
are resize
, sendMessage
, and moveToAnchor
which are exposed in the useImperativeHandle
hook here:
The iframeRef
is passed into the <iframe>
element here & that’s what I would like to be able to get access to:
https://github.com/davidjbradshaw/iframe-resizer-react/blob/03eea291dbde2ad29c72868c1249f739629a52d9/src/index.jsx#L42
However it is not accessible to parent components. Could a ref
passed into <IFrameResizer />
get forwarded to the <iframe>
element like the “Forwarding Refs” docs outlines? I don’t think any changes to the forwardRef
prop or the implementation of the useImperativeHandle
hook would be needed. This would be really helpful! Thanks for the great library! Also, here’s an annotated screenshot that might help:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:6
Top GitHub Comments
Up until now, I did not receive any feedback regarding the PR #53 😕 Dunno if and when it will be merged.
Bump