question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Making iframe-resizer work in React 0.15

See original GitHub issue
import { iframeResizer } from 'iframe-resizer'

export class Main extends Component {
  componentDidMount () {
    iframeResizer({log:true}, this.refs.iframe)
  }

  render () {
    return (
      <div>
        <iframe ref='iframe' src="some-page.html" width='100%'/>
      </div>
    )
  }
}

What am I missing? I can see the logs coming through and it seemingly is applying the resizer onto the iframe element, but it actually never triggers any resize events if the content height changes.

[iFrameSizer][Host page: iFrameResizer0] [iFrame.onload] Sending msg to iframe[iFrameResizer0] (iFrameResizer0:8:false:true:32:true:true:null:bodyOffset:null:null:0:false:parent:scroll) 
[iFrameSizer][Host page: document] Trigger event: Visiblity change
console.js:26 [iFrameSizer][Host page: window] Trigger event: focus

Likewise, resizedCallback never gets triggered either.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AllanPooleycommented, May 16, 2018

Hey gang,

Many thanks @davidjbradshaw for iframe-resizer, and @zeroasterisk for your react adaptation.

React frontend, pulling through complex plugin modified forms from a separate WordPress website (Headless WordPress website).

Thought I’d share my dead simple example for anyone else crawling the web for a react application of iframe-resizer.

On my react front-end:

Installation yarn add react-iframe-resizer-super iframe-resizer

import React from 'react';
import IframeResizer from 'react-iframe-resizer-super';

export const DynamicIFrame = props => {
  const { src } = props;
  const iframeResizerOptions = {
    log: true,
    // autoResize: true,
    checkOrigin: false,
    // resizeFrom: 'parent',
    // heightCalculationMethod: 'max',
    // initCallback: () => { console.log('ready!'); },
    // resizedCallback: () => { console.log('resized!'); },
  };
  return (
    <IframeResizer src={src} iframeResizerOptions={iframeResizerOptions} />
  );
};

Inside the project that is the source of my iFrame (WordPress): Include iframeResizer.contentWindow.min.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

iframe-resizer-react - npm
Start using iframe-resizer-react in your project by running `npm ... There are 52 other projects in the npm registry using iframe-resizer-react.
Read more >
Web Libraries in Jars - WebJars
Coffeescript React JSX Transformer, org.webjars, coffee-react-transform ... org.webjars.bower, github-com-angular-cron-jobs-angular-cron-jobs, 3.2.0.
Read more >
oss-product.txt - Glide Apps
This component takes a utils property, and makes it available down the React tree thanks to React context. It should preferably be used...
Read more >
Open Source Used In Socio 1.0 - Cisco
1.141 babel-helper-create-regexp-features-plugin 7.10.4 ... 1.393 iframe-resizer-react 1.1.0 ... represent, as a whole, an original work of authorship.
Read more >
Lighthouse Report - DashLord - Beta.gouv
node_modules/iframe-resizer-react/node_modules/iframe-resizer/js/ ... 0.15 s. Preload the image used by the LCP element in order to improve your LCP time.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found