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

Function mountLazyComponent

packages/react-reconciler/src/ReactFiberBeginWork.js:2077–2168  ·  view source on GitHub ↗
(
  _current: null | Fiber,
  workInProgress: Fiber,
  elementType: any,
  renderLanes: Lanes,
)

Source from the content-addressed store, hash-verified

2075}
2076
2077function mountLazyComponent(
2078 _current: null | Fiber,
2079 workInProgress: Fiber,
2080 elementType: any,
2081 renderLanes: Lanes,
2082) {
2083 resetSuspendedCurrentOnMountInLegacyMode(_current, workInProgress);
2084
2085 const props = workInProgress.pendingProps;
2086 const lazyComponent: LazyComponentType<any, any> = elementType;
2087 let Component = resolveLazy(lazyComponent);
2088 // Store the unwrapped component in the type.
2089 workInProgress.type = Component;
2090
2091 if (typeof Component === 'function') {
2092 if (isFunctionClassComponent(Component)) {
2093 const resolvedProps = resolveClassComponentProps(Component, props);
2094 workInProgress.tag = ClassComponent;
2095 if (__DEV__) {
2096 workInProgress.type = Component =
2097 resolveClassForHotReloading(Component);
2098 }
2099 return updateClassComponent(
2100 null,
2101 workInProgress,
2102 Component,
2103 resolvedProps,
2104 renderLanes,
2105 );
2106 } else {
2107 workInProgress.tag = FunctionComponent;
2108 if (__DEV__) {
2109 validateFunctionComponentInDev(workInProgress, Component);
2110 workInProgress.type = Component =
2111 resolveFunctionForHotReloading(Component);
2112 }
2113 return updateFunctionComponent(
2114 null,
2115 workInProgress,
2116 Component,
2117 props,
2118 renderLanes,
2119 );
2120 }
2121 } else if (Component !== undefined && Component !== null) {
2122 const $$typeof = Component.$$typeof;
2123 if ($$typeof === REACT_FORWARD_REF_TYPE) {
2124 workInProgress.tag = ForwardRef;
2125 if (__DEV__) {
2126 workInProgress.type = Component =
2127 resolveForwardRefForHotReloading(Component);
2128 }
2129 return updateForwardRef(
2130 null,
2131 workInProgress,
2132 Component,
2133 props,
2134 renderLanes,

Callers 1

beginWorkFunction · 0.85

Calls 13

resolveLazyFunction · 0.90
isFunctionClassComponentFunction · 0.90
updateClassComponentFunction · 0.85
updateFunctionComponentFunction · 0.85
updateForwardRefFunction · 0.85
updateMemoComponentFunction · 0.85
getComponentNameFromTypeFunction · 0.85

Tested by

no test coverage detected