MCPcopy
hub / github.com/testing-library/react-testing-library / createConcurrentRoot

Function createConcurrentRoot

src/pure.js:92–139  ·  view source on GitHub ↗
(
  container,
  {
    hydrate,
    onCaughtError,
    onRecoverableError,
    ui,
    wrapper: WrapperComponent,
    reactStrictMode,
  },
)

Source from the content-addressed store, hash-verified

90}
91
92function createConcurrentRoot(
93 container,
94 {
95 hydrate,
96 onCaughtError,
97 onRecoverableError,
98 ui,
99 wrapper: WrapperComponent,
100 reactStrictMode,
101 },
102) {
103 let root
104 if (hydrate) {
105 act(() => {
106 root = ReactDOMClient.hydrateRoot(
107 container,
108 strictModeIfNeeded(
109 wrapUiIfNeeded(ui, WrapperComponent),
110 reactStrictMode,
111 ),
112 {onCaughtError, onRecoverableError},
113 )
114 })
115 } else {
116 root = ReactDOMClient.createRoot(container, {
117 onCaughtError,
118 onRecoverableError,
119 })
120 }
121
122 return {
123 hydrate() {
124 /* istanbul ignore if */
125 if (!hydrate) {
126 throw new Error(
127 'Attempted to hydrate a non-hydrateable root. This is a bug in `@testing-library/react`.',
128 )
129 }
130 // Nothing to do since hydration happens when creating the root object.
131 },
132 render(element) {
133 root.render(element)
134 },
135 unmount() {
136 root.unmount()
137 },
138 }
139}
140
141function createLegacyRoot(container) {
142 return {

Callers

nothing calls this directly

Calls 2

strictModeIfNeededFunction · 0.85
wrapUiIfNeededFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…