MCPcopy
hub / github.com/vercel/next.js / renderReactElement

Function renderReactElement

packages/next/src/client/index.tsx:563–586  ·  view source on GitHub ↗
(
  domEl: HTMLElement,
  fn: (cb: () => void) => JSX.Element
)

Source from the content-addressed store, hash-verified

561}
562
563function 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
588function Root({
589 callbacks,

Callers 1

doRenderFunction · 0.85

Calls 4

markMethod · 0.80
renderMethod · 0.65
fnFunction · 0.50
startTransitionFunction · 0.50

Tested by

no test coverage detected