import { observable } from "mobx"; import { observer } from "mobx-react"; import { OpenIcon } from "outline-icons"; import * as React from "react"; import styled from "styled-components"; type Props = React.HTMLAttributes & { src?: string; border?: boolean; title?: string; icon?: React.ReactNode; canonicalUrl?: string; isSelected?: boolean; width?: string; height?: string; allow?: string; }; type PropsWithRef = Props & { forwardedRef: React.Ref; }; @observer class Frame extends React.Component { mounted: boolean; @observable isLoaded = false; componentDidMount() { this.mounted = true; setImmediate(this.loadIframe); } componentWillUnmount() { this.mounted = false; } loadIframe = () => { if (!this.mounted) { return; } this.isLoaded = true; }; render() { const { border, width = "100%", height = "400px", forwardedRef, icon, title, canonicalUrl, isSelected, src, } = this.props; const withBar = !!(icon || canonicalUrl); return ( {this.isLoaded && (