( domEl: HTMLElement, fn: (cb: () => void) => JSX.Element )
| 561 | } |
| 562 | |
| 563 | function renderReactElement( |
| 564 | domEl: HTMLElement, |
| 565 | fn: (cb: () => void) => JSX.Element |
| 566 | ): void { |
| 567 | // mark start of hydrate/render |
| 568 | if (ST) { |
| 569 | performance.mark(performanceMarks.beforeRender) |
| 570 | } |
| 571 | |
| 572 | const reactEl = fn(shouldHydrate ? markHydrateComplete : markRenderComplete) |
| 573 | if (!reactRoot) { |
| 574 | // Unlike with createRoot, you don't need a separate root.render() call here |
| 575 | reactRoot = ReactDOM.hydrateRoot(domEl, reactEl, { |
| 576 | onRecoverableError, |
| 577 | }) |
| 578 | // TODO: Remove shouldHydrate variable when React 18 is stable as it can depend on `reactRoot` existing |
| 579 | shouldHydrate = false |
| 580 | } else { |
| 581 | const startTransition = (React as any).startTransition |
| 582 | startTransition(() => { |
| 583 | reactRoot.render(reactEl) |
| 584 | }) |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | function Root({ |
| 589 | callbacks, |
no test coverage detected