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

Function Root

packages/next/src/client/index.tsx:588–614  ·  view source on GitHub ↗
({
  callbacks,
  children,
}: React.PropsWithChildren<{
  callbacks: Array<() => void>
}>)

Source from the content-addressed store, hash-verified

586}
587
588function Root({
589 callbacks,
590 children,
591}: React.PropsWithChildren<{
592 callbacks: Array<() => void>
593}>): React.ReactElement {
594 // We use `useLayoutEffect` to guarantee the callbacks are executed
595 // as soon as React flushes the update
596 React.useLayoutEffect(
597 () => callbacks.forEach((callback) => callback()),
598 [callbacks]
599 )
600
601 if (process.env.__NEXT_TEST_MODE) {
602 // eslint-disable-next-line react-hooks/rules-of-hooks
603 React.useEffect(() => {
604 window.__NEXT_HYDRATED = true
605 window.__NEXT_HYDRATED_AT = performance.now()
606
607 if (window.__NEXT_HYDRATED_CB) {
608 window.__NEXT_HYDRATED_CB()
609 }
610 }, [])
611 }
612
613 return children as React.ReactElement
614}
615
616function doRender(input: RenderRouteInfo): Promise<any> {
617 let { App, Component, props, err }: RenderRouteInfo = input

Callers

nothing calls this directly

Calls 3

callbackFunction · 0.70
forEachMethod · 0.45
nowMethod · 0.45

Tested by

no test coverage detected