Simple react component to embeded iframed page and give a callback when completed load content
npm install react-simple-iframe
OR
yarn add react-simple-iframe
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Iframe from 'react-simple-iframe'
class App extends Component {
state = {
iframeLoaded: false
}
handleLoadedIframe = () => {
this.setState({ iframeLoaded: true })
}
render() {
const { iframeLoaded } = this.state
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
{ !iframeLoaded && <p>LOADING....</p> }
<Iframe
src='https://www.google.com'
frameBorder='0'
onLoaded={this.handleLoadedIframe}
/>
</div>
);
}
}
export default App;
You can pass all standard properties <iframe />
but this component provide additional properties:
onLoaded - function
MIT. Copyright Ihsan Satriawan, and other contributors.