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

Function createFiberFromElement

code/communication/public/app.js:6990–7074  ·  view source on GitHub ↗
(element, mode, expirationTime)

Source from the content-addressed store, hash-verified

6988}
6989
6990function createFiberFromElement(element, mode, expirationTime) {
6991 var owner = null;
6992 {
6993 owner = element._owner;
6994 }
6995
6996 var fiber = void 0;
6997 var type = element.type;
6998 var key = element.key;
6999 var pendingProps = element.props;
7000
7001 var fiberTag = void 0;
7002 if (typeof type === 'function') {
7003 fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent;
7004 } else if (typeof type === 'string') {
7005 fiberTag = HostComponent;
7006 } else {
7007 switch (type) {
7008 case REACT_FRAGMENT_TYPE:
7009 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
7010 case REACT_ASYNC_MODE_TYPE:
7011 fiberTag = Mode;
7012 mode |= AsyncMode | StrictMode;
7013 break;
7014 case REACT_STRICT_MODE_TYPE:
7015 fiberTag = Mode;
7016 mode |= StrictMode;
7017 break;
7018 case REACT_CALL_TYPE:
7019 fiberTag = CallComponent;
7020 break;
7021 case REACT_RETURN_TYPE:
7022 fiberTag = ReturnComponent;
7023 break;
7024 default:
7025 {
7026 if (typeof type === 'object' && type !== null) {
7027 switch (type.$$typeof) {
7028 case REACT_PROVIDER_TYPE:
7029 fiberTag = ContextProvider;
7030 break;
7031 case REACT_CONTEXT_TYPE:
7032 // This is a consumer
7033 fiberTag = ContextConsumer;
7034 break;
7035 case REACT_FORWARD_REF_TYPE:
7036 fiberTag = ForwardRef;
7037 break;
7038 default:
7039 if (typeof type.tag === 'number') {
7040 // Currently assumed to be a continuation and therefore is a
7041 // fiber already.
7042 // TODO: The yield system is currently broken for updates in
7043 // some cases. The reified yield stores a fiber, but we don't
7044 // know which fiber that is; the current or a workInProgress?
7045 // When the continuation gets rendered here we don't know if we
7046 // can reuse that fiber or if we need to clone it. There is
7047 // 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