Skip to content

Frame re-renders on each load event inside iframe #198

@igorbt

Description

@igorbt

React bubble up to the Frame component (iframe) each load event that happen in elements rendered inside it, even if browsers normally would stop this at iframe border. This is why on each such load (for example image load) Frame->handleLoad is called and the unconditional setState there would re-render the Frame.
For now I'm using a workaround like this:

<Frame>
  <div onLoad={ev => ev.stopPropagation()}>{children}</div>
</Frame>

But it would be nice to have a fix in the library. For example at least:

  handleLoad = () => {
    if (!this.state.iframeLoaded) {
      this.setState({ iframeLoaded: true });
    }
  };

or, maybe checking that the event target is really the iframe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions