I have a simple component that loads a 3rd party script that would inject some iframes to a div. I want to empty the div when the reset button is clicked. Since the content of the div is injected by a 3rd party script that is outside of react, the content does not clear when it rerenders. I have tried adding a key with current timestamp to the div but did not work. Any idea how to achieve this without using innterHTML = '' or empty DOM elements using vanilla javascript?
const App = () => {
  useEffect(() => {
    ... load a 3rd party script which then inject some iframes into #container
  }, []);
  const reset = () => {
    // how to empty the div #container
  };
 
  return (
    <div>
      <div id="container" />
      <button type="button" onClick={reset}>reset</button>
    </div>
  )
}
UPDATE: I figured this out. Setting key with timestamp worked. It is actually another issue causing it is not updating
 
     
    