MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / createFiberFromElement

Function createFiberFromElement

code/third-party/public/app.js:6188–6272  ·  view source on GitHub ↗
(element, mode, expirationTime)

Source from the content-addressed store, hash-verified

6186}
6187
6188function createFiberFromElement(element, mode, expirationTime) {
6189 var owner = null;
6190 {
6191 owner = element._owner;
6192 }
6193
6194 var fiber = void 0;
6195 var type = element.type;
6196 var key = element.key;
6197 var pendingProps = element.props;
6198
6199 var fiberTag = void 0;
6200 if (typeof type === 'function') {
6201 fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent;
6202 } else if (typeof type === 'string') {
6203 fiberTag = HostComponent;
6204 } else {
6205 switch (type) {
6206 case REACT_FRAGMENT_TYPE:
6207 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
6208 case REACT_ASYNC_MODE_TYPE:
6209 fiberTag = Mode;
6210 mode |= AsyncMode | StrictMode;
6211 break;
6212 case REACT_STRICT_MODE_TYPE:
6213 fiberTag = Mode;
6214 mode |= StrictMode;
6215 break;
6216 case REACT_CALL_TYPE:
6217 fiberTag = CallComponent;
6218 break;
6219 case REACT_RETURN_TYPE:
6220 fiberTag = ReturnComponent;
6221 break;
6222 default:
6223 {
6224 if (typeof type === 'object' && type !== null) {
6225 switch (type.$$typeof) {
6226 case REACT_PROVIDER_TYPE:
6227 fiberTag = ContextProvider;
6228 break;
6229 case REACT_CONTEXT_TYPE:
6230 // This is a consumer
6231 fiberTag = ContextConsumer;
6232 break;
6233 case REACT_FORWARD_REF_TYPE:
6234 fiberTag = ForwardRef;
6235 break;
6236 default:
6237 if (typeof type.tag === 'number') {
6238 // Currently assumed to be a continuation and therefore is a
6239 // fiber already.
6240 // TODO: The yield system is currently broken for updates in
6241 // some cases. The reified yield stores a fiber, but we don't
6242 // know which fiber that is; the current or a workInProgress?
6243 // When the continuation gets rendered here we don't know if we
6244 // can reuse that fiber or if we need to clone it. There is
6245 // probably a clever way to restructure this.

Callers 3

updateElementFunction · 0.70
createChildFunction · 0.70
reconcileSingleElementFunction · 0.70

Calls 4

shouldConstructFunction · 0.70
createFiberFromFragmentFunction · 0.70
createFiberFunction · 0.70

Tested by

no test coverage detected