Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get onload event? #19

Closed
fifyrio opened this issue Feb 5, 2018 · 3 comments
Closed

how to get onload event? #19

fifyrio opened this issue Feb 5, 2018 · 3 comments

Comments

@fifyrio
Copy link

fifyrio commented Feb 5, 2018

Hi, buddy, how to get onload event?

@rm-rf-etc
Copy link

@fifyrio as it's implemented now, this library won't support it, but if you simply copy the contents of https://github.com/svenanders/react-iframe/blob/master/index.js to your project, you can add support for onLoad. That's what I did, here's the code.

const Iframe = class extends PureComponent {

	render() {

		const props = {
			ref: 'iframe',
			frameBorder: '0',
			src: this.props.url,
			target: '_parent',
			allowFullScreen: this.props.allowFullScreen || false,
			style: Object.assign(
				{
					position: this.props.position || 'absolute',
					display: this.props.display || 'block',
					height: this.props.height || '100%',
					width: this.props.width || '100%',
				},
				this.props.styles || {},
			),
			height: this.props.height || '100%',
			name: this.props.name || '',
			width: this.props.width || '100%',
			onLoad: this.props.onLoad ? this.props.onLoad : undefined,
		}

		const { id, className } = this.props

		return React.createElement(
			'iframe',
			Object.assign(props, id ? id : null, className ? className : null),
		)
	}
}

@fifyrio
Copy link
Author

fifyrio commented May 23, 2018

Thanks

@foxmicha
Copy link
Contributor

foxmicha commented Jun 27, 2018

With the merge and release of PR #24 this is now supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants