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

Function create

packages/react-test-renderer/src/ReactTestRenderer.js:467–631  ·  view source on GitHub ↗
(
  element: React$Element<any>,
  options: TestRendererOptions,
)

Source from the content-addressed store, hash-verified

465}
466
467function create(
468 element: React$Element<any>,
469 options: TestRendererOptions,
470): {
471 _Scheduler: typeof Scheduler,
472 root: void,
473 toJSON(): Array<ReactTestRendererNode> | ReactTestRendererNode | null,
474 toTree(): mixed,
475 update(newElement: React$Element<any>): any,
476 unmount(): void,
477 getInstance(): component(...props: any) | PublicInstance | null,
478 unstable_flushSync: typeof flushSyncFromReconciler,
479} {
480 if (__DEV__) {
481 if (
482 enableReactTestRendererWarning === true &&
483 global.IS_REACT_NATIVE_TEST_ENVIRONMENT !== true
484 ) {
485 console.error(
486 'react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer',
487 );
488 }
489 }
490
491 let createNodeMock = defaultTestOptions.createNodeMock;
492 const isConcurrentOnly =
493 disableLegacyMode === true &&
494 global.IS_REACT_NATIVE_TEST_ENVIRONMENT !== true;
495 let isConcurrent = isConcurrentOnly;
496 let isStrictMode = false;
497 if (typeof options === 'object' && options !== null) {
498 if (typeof options.createNodeMock === 'function') {
499 // $FlowFixMe[incompatible-type] found when upgrading Flow
500 createNodeMock = options.createNodeMock;
501 }
502 if (isConcurrentOnly === false) {
503 isConcurrent = options.unstable_isConcurrent;
504 }
505 if (options.unstable_strictMode === true) {
506 isStrictMode = true;
507 }
508 }
509 let container: Container = {
510 children: ([]: Array<Instance | TextInstance>),
511 createNodeMock,
512 tag: 'CONTAINER',
513 };
514 let root: FiberRoot | null = createContainer(
515 container,
516 isConcurrent ? ConcurrentRoot : LegacyRoot,
517 null,
518 isStrictMode,
519 false,
520 '',
521 defaultOnUncaughtError,
522 defaultOnCaughtError,
523 defaultOnRecoverableError,
524 defaultOnDefaultTransitionIndicator,

Callers 4

ReactFiberHooks.jsFile · 0.50
ifFunction · 0.50

Calls 5

createContainerFunction · 0.90
updateContainerFunction · 0.90
wrapFiberFunction · 0.85
getChildrenFunction · 0.70
errorMethod · 0.65

Tested by

no test coverage detected