MCPcopy Index your code
hub / github.com/react/react / hydrateRoot

Function hydrateRoot

packages/react-dom/src/client/ReactDOMRoot.js:274–358  ·  view source on GitHub ↗
(
  container: Document | Element,
  initialChildren: ReactNodeList,
  options?: HydrateRootOptions,
)

Source from the content-addressed store, hash-verified

272ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = scheduleHydration;
273
274export function hydrateRoot(
275 container: Document | Element,
276 initialChildren: ReactNodeList,
277 options?: HydrateRootOptions,
278): RootType {
279 if (!isValidContainer(container)) {
280 throw new Error('Target container is not a DOM element.');
281 }
282
283 warnIfReactDOMContainerInDEV(container);
284
285 if (__DEV__) {
286 if (initialChildren === undefined) {
287 console.error(
288 'Must provide initial children as second argument to hydrateRoot. ' +
289 'Example usage: hydrateRoot(domContainer, <App />)',
290 );
291 }
292 }
293
294 // For now we reuse the whole bag of options since they contain
295 // the hydration callbacks.
296 const hydrationCallbacks = options != null ? options : null;
297
298 const concurrentUpdatesByDefaultOverride = false;
299 let isStrictMode = false;
300 let identifierPrefix = '';
301 let onUncaughtError = defaultOnUncaughtError;
302 let onCaughtError = defaultOnCaughtError;
303 let onRecoverableError = defaultOnRecoverableError;
304 let onDefaultTransitionIndicator = defaultOnDefaultTransitionIndicator;
305 let transitionCallbacks = null;
306 let formState = null;
307 if (options !== null && options !== undefined) {
308 if (options.unstable_strictMode === true) {
309 isStrictMode = true;
310 }
311 if (options.identifierPrefix !== undefined) {
312 identifierPrefix = options.identifierPrefix;
313 }
314 if (options.onUncaughtError !== undefined) {
315 onUncaughtError = options.onUncaughtError;
316 }
317 if (options.onCaughtError !== undefined) {
318 onCaughtError = options.onCaughtError;
319 }
320 if (options.onRecoverableError !== undefined) {
321 onRecoverableError = options.onRecoverableError;
322 }
323 if (enableDefaultTransitionIndicator) {
324 if (options.onDefaultTransitionIndicator !== undefined) {
325 onDefaultTransitionIndicator = options.onDefaultTransitionIndicator;
326 }
327 }
328 if (options.unstable_transitionCallbacks !== undefined) {
329 transitionCallbacks = options.unstable_transitionCallbacks;
330 }
331 if (options.formState !== undefined) {

Callers 2

index.jsFile · 0.90
index.jsFile · 0.90

Calls 6

isValidContainerFunction · 0.90
createHydrationContainerFunction · 0.90
markContainerAsRootFunction · 0.90
errorMethod · 0.65

Tested by

no test coverage detected