renderDom.tsx 479 B

123456789101112131415161718
  1. import {createRoot} from 'react-dom/client';
  2. export function renderDom(
  3. Component: React.ComponentType,
  4. container: string,
  5. props: Record<string, any> = {}
  6. ) {
  7. const rootEl = document.querySelector(container);
  8. // Note: On pages like `SetupWizard`, we will attempt to mount main App
  9. // but will fail because the DOM el wasn't found (which is intentional)
  10. if (!rootEl) {
  11. return;
  12. }
  13. const root = createRoot(rootEl);
  14. root.render(<Component {...props} />);
  15. }