MCPcopy Create free account
hub / github.com/react/react / mountComponent

Function mountComponent

packages/react-devtools-shared/src/backend/legacy/renderer.js:223–268  ·  view source on GitHub ↗
(fn, args)

Source from the content-addressed store, hash-verified

221 // React 15
222 oldReconcilerMethods = decorateMany(renderer.Reconciler, {
223 mountComponent(fn, args) {
224 const internalInstance = args[0];
225 const hostContainerInfo = args[3];
226 if (getElementType(internalInstance) === ElementTypeOtherOrUnknown) {
227 // $FlowFixMe[object-this-reference] found when upgrading Flow
228 return fn.apply(this, args);
229 }
230 if (hostContainerInfo._topLevelWrapper === undefined) {
231 // SSR
232 // $FlowFixMe[object-this-reference] found when upgrading Flow
233 return fn.apply(this, args);
234 }
235
236 const id = getID(internalInstance);
237 // Push the operation.
238 const parentID =
239 parentIDStack.length > 0
240 ? parentIDStack[parentIDStack.length - 1]
241 : 0;
242 recordMount(internalInstance, id, parentID);
243 parentIDStack.push(id);
244
245 // Remember the root.
246 internalInstanceToRootIDMap.set(
247 internalInstance,
248 getID(hostContainerInfo._topLevelWrapper),
249 );
250
251 try {
252 // $FlowFixMe[object-this-reference] found when upgrading Flow
253 const result = fn.apply(this, args);
254 parentIDStack.pop();
255 return result;
256 } catch (err) {
257 parentIDStack = [];
258 throw err;
259 } finally {
260 if (parentIDStack.length === 0) {
261 const rootID = internalInstanceToRootIDMap.get(internalInstance);
262 if (rootID === undefined) {
263 throw new Error('Expected to find root ID.');
264 }
265 flushPendingEvents(rootID);
266 }
267 }
268 },
269 performUpdateIfNecessary(fn, args) {
270 const internalInstance = args[0];
271 if (getElementType(internalInstance) === ElementTypeOtherOrUnknown) {

Calls 9

getElementTypeFunction · 0.85
getIDFunction · 0.85
setMethod · 0.80
recordMountFunction · 0.70
flushPendingEventsFunction · 0.70
pushMethod · 0.65
popMethod · 0.65
getMethod · 0.65
applyMethod · 0.45

Tested by

no test coverage detected