import { createRoot } from 'react-dom/client';
import App from './App';
import './App.css';

let root = null;

function mountHome() {
  const container = document.getElementById('wowext-home-root');
  if (!container) {
    return;
  }
  if (root) {
    root.unmount();
    root = null;
  }
  root = createRoot(container);
  root.render(<App />);
}

function unmountHome() {
  if (root) {
    root.unmount();
    root = null;
  }
}

if (document.getElementById('wowext-home-root')) {
  mountHome();
}

window.wowextMountHome = mountHome;
window.wowextUnmountHome = unmountHome;
