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

Function createFiberFromElement

code/styling/public/app.js:6955–7039  ·  view source on GitHub ↗
(element, mode, expirationTime)

Source from the content-addressed store, hash-verified

6953}
6954
6955function createFiberFromElement(element, mode, expirationTime) {
6956 var owner = null;
6957 {
6958 owner = element._owner;
6959 }
6960
6961 var fiber = void 0;
6962 var type = element.type;
6963 var key = element.key;
6964 var pendingProps = element.props;
6965
6966 var fiberTag = void 0;
6967 if (typeof type === 'function') {
6968 fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent;
6969 } else if (typeof type === 'string') {
6970 fiberTag = HostComponent;
6971 } else {
6972 switch (type) {
6973 case REACT_FRAGMENT_TYPE:
6974 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
6975 case REACT_ASYNC_MODE_TYPE:
6976 fiberTag = Mode;
6977 mode |= AsyncMode | StrictMode;
6978 break;
6979 case REACT_STRICT_MODE_TYPE:
6980 fiberTag = Mode;
6981 mode |= StrictMode;
6982 break;
6983 case REACT_CALL_TYPE:
6984 fiberTag = CallComponent;
6985 break;
6986 case REACT_RETURN_TYPE:
6987 fiberTag = ReturnComponent;
6988 break;
6989 default:
6990 {
6991 if (typeof type === 'object' && type !== null) {
6992 switch (type.$$typeof) {
6993 case REACT_PROVIDER_TYPE:
6994 fiberTag = ContextProvider;
6995 break;
6996 case REACT_CONTEXT_TYPE:
6997 // This is a consumer
6998 fiberTag = ContextConsumer;
6999 break;
7000 case REACT_FORWARD_REF_TYPE:
7001 fiberTag = ForwardRef;
7002 break;
7003 default:
7004 if (typeof type.tag === 'number') {
7005 // Currently assumed to be a continuation and therefore is a
7006 // fiber already.
7007 // TODO: The yield system is currently broken for updates in
7008 // some cases. The reified yield stores a fiber, but we don't
7009 // know which fiber that is; the current or a workInProgress?
7010 // When the continuation gets rendered here we don't know if we
7011 // can reuse that fiber or if we need to clone it. There is
7012 // 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