Releases: ryanseddon/react-frame-component
v5.2.0
Forwarding iframe ref
Allow to pass ref
prop to Frame component which will allow to reach the inner iframe HTMLIFrameElement
.
The ref
forwarding is done by React.forwardRef
helper which wraps the original Frame class component instance.
Example usage:
function Foo() {
const iframeRef = React.useRef()
React.useEffect(() => {
iframeRef.style.setProperty('background-color', 'pink');
}, [])
<Frame ref={iframeRef} />
}
Other changes
5.1.0
Adds new useFrame
hook for access to iframes window
and document
host objects without the need for the context render prop pattern.
import { useFrame } from 'react-frame-component';
function Foo (props) {
const { window, document } = useFrame();
/* rest of the component */
}
5.0.1
Switch from doc.write to srcDoc
This is a breaking change
This library now uses srcDoc
which means no support for IE11 in v5 if you need IE11 support you can continue to use v4.1.3.
srcDoc is also async vs doc.write being sync, this will mostly go unnoticed in most use cases. However if you're relying on this library in unit tests you may need to convert those test to async aware tests. This means you'll need to use the done
callback in most unit test frameworks.
Why the change?
document.write is now bad practice for performance reasons and will be flagged accordingly in various web perf testing tools, srcDoc is a viable alternative without the perf downsides.
Commits
v5.0.0-alpha.0
This pre-release is testing whether srcdoc
usage over doc.write()
is a better move going forward. It's a breaking change as srcdoc
is async.
By changing to srcdoc
this will drop support for IE11.