renderPipelineView.tsx 1.0 KB

123456789101112131415161718192021222324252627282930
  1. import {render} from 'react-dom';
  2. import {createRoot} from 'react-dom/client';
  3. import {ROOT_ELEMENT, USE_REACT_CONCURRENT_MODE} from 'sentry/constants';
  4. import type {PipelineInitialData} from 'sentry/types';
  5. import PipelineView from 'sentry/views/integrationPipeline/pipelineView';
  6. function renderDom(pipelineName: string, props: PipelineInitialData['props']) {
  7. const rootEl = document.getElementById(ROOT_ELEMENT)!;
  8. // Types are for ConfigStore, the window object is from json and features is not a Set
  9. if (
  10. (window.__initialData.features as unknown as string[]).includes(
  11. 'organizations:react-concurrent-renderer-enabled'
  12. ) ||
  13. USE_REACT_CONCURRENT_MODE
  14. ) {
  15. // Enable concurrent rendering
  16. const root = createRoot(rootEl);
  17. root.render(<PipelineView pipelineName={pipelineName} {...props} />);
  18. } else {
  19. // Legacy rendering
  20. render(<PipelineView pipelineName={pipelineName} {...props} />, rootEl);
  21. }
  22. }
  23. export function renderPipelineView() {
  24. const {name, props} = window.__pipelineInitialData;
  25. renderDom(name, props);
  26. }