What's the best way to periodically reload an iframe with React?

后端 未结 2 1803
一整个雨季
一整个雨季 2021-01-23 18:28

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

2条回答
  •  自闭症患者
    2021-01-23 18:44

    Change key property for component for example:

    this.state = {iframeKey: 0};
    
    setInterval(() => this.setState(s => ({iframeKey: s.iframeKey + 1})), 1000);