Created
October 29, 2018 09:42
-
-
Save asci/5f1afb9a772392adf318c624deac9a7a to your computer and use it in GitHub Desktop.
Iframe React issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Could be served via CRA with default port 3000 | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { num: 0 }; | |
} | |
componentDidMount() { | |
setInterval(() => { | |
this.setState({ num: this.state.num + 1 }); | |
}, 1000); | |
} | |
render() { | |
return ( | |
<div className="App"> | |
<h1>To trigger updates {this.state.num}</h1> | |
<iframe | |
width="300" | |
height="200" | |
src="http://localhost:8000/index.html" | |
/> | |
</div> | |
); | |
} | |
} | |
const rootElement = document.getElementById('root'); | |
ReactDOM.render(<App />, rootElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- SHOULD BE SERVED FROM DIFFERENT LOCATION\PORT --> | |
<!-- eg. http://localhost:8000 I used `python -m SimpleHTTPServer 8000 .` --> | |
<!DOCTYPE HTML> | |
<html> | |
<head> | |
</head> | |
<body> | |
<textarea>This</textarea> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment