MCPcopy
hub / github.com/facebook/react / createFiberRoot

Function createFiberRoot

packages/react-reconciler/src/ReactFiberRoot.js:158–237  ·  view source on GitHub ↗
(
  containerInfo: Container,
  tag: RootTag,
  hydrate: boolean,
  initialChildren: ReactNodeList,
  hydrationCallbacks: null | SuspenseHydrationCallbacks,
  isStrictMode: boolean,
  // TODO: We have several of these arguments that are conceptually part of the
  // host config, but because they are passed in at runtime, we have to thread
  // them through the root constructor. Perhaps we should put them all into a
  // single type, like a DynamicHostConfig that is defined by the renderer.
  identifierPrefix: string,
  formState: ReactFormState<any, any> | null,
  onUncaughtError: (
    error: mixed,
    errorInfo: {+componentStack?: ?string},
  ) => void,
  onCaughtError: (
    error: mixed,
    errorInfo: {
      +componentStack?: ?string,
      +errorBoundary?: ?component(...props: any),
    },
  ) => void,
  onRecoverableError: (
    error: mixed,
    errorInfo: {+componentStack?: ?string},
  ) => void,
  onDefaultTransitionIndicator: () => void | (() => void),
  transitionCallbacks: null | TransitionTracingCallbacks,
)

Source from the content-addressed store, hash-verified

156}
157
158export function createFiberRoot(
159 containerInfo: Container,
160 tag: RootTag,
161 hydrate: boolean,
162 initialChildren: ReactNodeList,
163 hydrationCallbacks: null | SuspenseHydrationCallbacks,
164 isStrictMode: boolean,
165 // TODO: We have several of these arguments that are conceptually part of the
166 // host config, but because they are passed in at runtime, we have to thread
167 // them through the root constructor. Perhaps we should put them all into a
168 // single type, like a DynamicHostConfig that is defined by the renderer.
169 identifierPrefix: string,
170 formState: ReactFormState<any, any> | null,
171 onUncaughtError: (
172 error: mixed,
173 errorInfo: {+componentStack?: ?string},
174 ) => void,
175 onCaughtError: (
176 error: mixed,
177 errorInfo: {
178 +componentStack?: ?string,
179 +errorBoundary?: ?component(...props: any),
180 },
181 ) => void,
182 onRecoverableError: (
183 error: mixed,
184 errorInfo: {+componentStack?: ?string},
185 ) => void,
186 onDefaultTransitionIndicator: () => void | (() => void),
187 transitionCallbacks: null | TransitionTracingCallbacks,
188): FiberRoot {
189 // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
190 const root: FiberRoot = (new FiberRootNode(
191 containerInfo,
192 tag,
193 hydrate,
194 identifierPrefix,
195 onUncaughtError,
196 onCaughtError,
197 onRecoverableError,
198 onDefaultTransitionIndicator,
199 formState,
200 ): any);
201 if (enableSuspenseCallback) {
202 root.hydrationCallbacks = hydrationCallbacks;
203 }
204
205 if (enableTransitionTracing) {
206 root.transitionCallbacks = transitionCallbacks;
207 }
208
209 // Cyclic construction. This cheats the type system right now because
210 // stateNode is any.
211 const uninitializedFiber = createHostRootFiber(tag, isStrictMode);
212 root.current = uninitializedFiber;
213 uninitializedFiber.stateNode = root;
214
215 const initialCache = createCache();

Callers 2

createContainerFunction · 0.90
createHydrationContainerFunction · 0.90

Calls 4

createHostRootFiberFunction · 0.90
createCacheFunction · 0.90
retainCacheFunction · 0.90
initializeUpdateQueueFunction · 0.90

Tested by

no test coverage detected