MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / createFiberFromElement

Function createFiberFromElement

code/composition/public/app.js:7093–7177  ·  view source on GitHub ↗
(element, mode, expirationTime)

Source from the content-addressed store, hash-verified

7091}
7092
7093function createFiberFromElement(element, mode, expirationTime) {
7094 var owner = null;
7095 {
7096 owner = element._owner;
7097 }
7098
7099 var fiber = void 0;
7100 var type = element.type;
7101 var key = element.key;
7102 var pendingProps = element.props;
7103
7104 var fiberTag = void 0;
7105 if (typeof type === 'function') {
7106 fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent;
7107 } else if (typeof type === 'string') {
7108 fiberTag = HostComponent;
7109 } else {
7110 switch (type) {
7111 case REACT_FRAGMENT_TYPE:
7112 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
7113 case REACT_ASYNC_MODE_TYPE:
7114 fiberTag = Mode;
7115 mode |= AsyncMode | StrictMode;
7116 break;
7117 case REACT_STRICT_MODE_TYPE:
7118 fiberTag = Mode;
7119 mode |= StrictMode;
7120 break;
7121 case REACT_CALL_TYPE:
7122 fiberTag = CallComponent;
7123 break;
7124 case REACT_RETURN_TYPE:
7125 fiberTag = ReturnComponent;
7126 break;
7127 default:
7128 {
7129 if (typeof type === 'object' && type !== null) {
7130 switch (type.$$typeof) {
7131 case REACT_PROVIDER_TYPE:
7132 fiberTag = ContextProvider;
7133 break;
7134 case REACT_CONTEXT_TYPE:
7135 // This is a consumer
7136 fiberTag = ContextConsumer;
7137 break;
7138 case REACT_FORWARD_REF_TYPE:
7139 fiberTag = ForwardRef;
7140 break;
7141 default:
7142 if (typeof type.tag === 'number') {
7143 // Currently assumed to be a continuation and therefore is a
7144 // fiber already.
7145 // TODO: The yield system is currently broken for updates in
7146 // some cases. The reified yield stores a fiber, but we don't
7147 // know which fiber that is; the current or a workInProgress?
7148 // When the continuation gets rendered here we don't know if we
7149 // can reuse that fiber or if we need to clone it. There is
7150 // 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