I'm building a webpage using React which means I can't manipulate the DOM directly. I've tried reloading my iframe by updating the url state but that doesn't seem to reload the page. This is the state code I have tried.
componentDidMount: function() {
setInterval(function(){
this.setState({currentUrl:currentUrl});
}.bind(this), 1000);
},
getInitialState: function() {
return {defaultUrl:this.props.graph.url, currentUrl:this.props.graph.url};
},
render() {
// render the graph iframe
return (
)
}
解决方案
Change key property for component
for example:
this.state = {iframeKey: 0};
setInterval(() => this.setState(s => ({iframeKey: s.iframeKey + 1})), 1000);