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

Function createRoot

packages/react-dom/src/client/ReactDOMRoot.js:171–260  ·  view source on GitHub ↗
(
  container: Element | Document | DocumentFragment,
  options?: CreateRootOptions,
)

Source from the content-addressed store, hash-verified

169 };
170
171export function createRoot(
172 container: Element | Document | DocumentFragment,
173 options?: CreateRootOptions,
174): RootType {
175 if (!isValidContainer(container)) {
176 throw new Error('Target container is not a DOM element.');
177 }
178
179 warnIfReactDOMContainerInDEV(container);
180
181 const concurrentUpdatesByDefaultOverride = false;
182 let isStrictMode = false;
183 let identifierPrefix = '';
184 let onUncaughtError = defaultOnUncaughtError;
185 let onCaughtError = defaultOnCaughtError;
186 let onRecoverableError = defaultOnRecoverableError;
187 let onDefaultTransitionIndicator = defaultOnDefaultTransitionIndicator;
188 let transitionCallbacks = null;
189
190 if (options !== null && options !== undefined) {
191 if (__DEV__) {
192 if ((options: any).hydrate) {
193 console.warn(
194 'hydrate through createRoot is deprecated. Use ReactDOMClient.hydrateRoot(container, <App />) instead.',
195 );
196 } else {
197 if (
198 typeof options === 'object' &&
199 options !== null &&
200 (options: any).$$typeof === REACT_ELEMENT_TYPE
201 ) {
202 console.error(
203 'You passed a JSX element to createRoot. You probably meant to ' +
204 'call root.render instead. ' +
205 'Example usage:\n\n' +
206 ' let root = createRoot(domContainer);\n' +
207 ' root.render(<App />);',
208 );
209 }
210 }
211 }
212 if (options.unstable_strictMode === true) {
213 isStrictMode = true;
214 }
215 if (options.identifierPrefix !== undefined) {
216 identifierPrefix = options.identifierPrefix;
217 }
218 if (options.onUncaughtError !== undefined) {
219 onUncaughtError = options.onUncaughtError;
220 }
221 if (options.onCaughtError !== undefined) {
222 onCaughtError = options.onCaughtError;
223 }
224 if (options.onRecoverableError !== undefined) {
225 onRecoverableError = options.onRecoverableError;
226 }
227 if (enableDefaultTransitionIndicator) {
228 if (options.onDefaultTransitionIndicator !== undefined) {

Callers 14

initializeTabFunction · 0.90
reloadFunction · 0.90
devtools.jsFile · 0.90
right.jsFile · 0.90
left.jsFile · 0.90
initFunction · 0.90
mountAppFunction · 0.90
mountAppFunction · 0.90
mountStrictAppFunction · 0.90
connectFunction · 0.90
createBridgeAndStoreFunction · 0.90
index.jsFile · 0.90

Calls 6

isValidContainerFunction · 0.90
createContainerFunction · 0.90
markContainerAsRootFunction · 0.90
errorMethod · 0.65

Tested by

no test coverage detected