Skip to content

v1.0.0

Compare
Choose a tag to compare
@cheton cheton released this 21 Dec 09:27
· 4 commits to master since this release

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);
    }}
/>