renderDom.tsx 472 B

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