v1.0.0
This release contains a breaking change that requires React v16.3 (or above) for using the new static method getDerivedStateFromProps
.
To resize Iframe to fit content, you can use native ResizeObserver when available, or a polyfill for the ResizeObserver API:
<Iframe
src="iframe.html"
onLoad={({ event, iframe }) => {
if (!(iframe && iframe.contentDocument)) {
return;
}
const target = iframe.contentDocument.body;
const nextHeight = target.offsetHeight;
iframe.style.height = `${nextHeight}px`;
const observer = new ResizeObserver(entries => {
const target = iframe.contentDocument.body;
const nextHeight = target.offsetHeight;
iframe.style.height = `${nextHeight}px`;
});
observer.observe(target);
}}
/>