Skip to content

Instantly share code, notes, and snippets.

@davo
Created July 24, 2018 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davo/9566d4bd0a87340de0e2c17197632bf3 to your computer and use it in GitHub Desktop.
Save davo/9566d4bd0a87340de0e2c17197632bf3 to your computer and use it in GitHub Desktop.
Iframe Component for Catalog
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'
class Iframe extends Component {
static propTypes: Object = {
src: PropTypes.string.isRequired,
onLoad: PropTypes.func,
}
componentDidMount () {
let iframe = ReactDOM.findDOMNode(this.refs.iframe)
iframe.addEventListener('load', this.props.onLoad);
}
render () {
const iframeStyle = {
width: '100%',
height: '100%',
border: '0',
position: 'absolute',
}
return (
<iframe
ref="iframe"
{...this.props}
frameBorder={'0'}
width={'100%'}
height={'100%'}
style={iframeStyle}
/>
)
}
}
export default Iframe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment