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

Function createFiberFromElement

code/new-context-api/public/app.js:6316–6400  ·  view source on GitHub ↗
(element, mode, expirationTime)

Source from the content-addressed store, hash-verified

6314}
6315
6316function createFiberFromElement(element, mode, expirationTime) {
6317 var owner = null;
6318 {
6319 owner = element._owner;
6320 }
6321
6322 var fiber = void 0;
6323 var type = element.type;
6324 var key = element.key;
6325 var pendingProps = element.props;
6326
6327 var fiberTag = void 0;
6328 if (typeof type === 'function') {
6329 fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent;
6330 } else if (typeof type === 'string') {
6331 fiberTag = HostComponent;
6332 } else {
6333 switch (type) {
6334 case REACT_FRAGMENT_TYPE:
6335 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
6336 case REACT_ASYNC_MODE_TYPE:
6337 fiberTag = Mode;
6338 mode |= AsyncMode | StrictMode;
6339 break;
6340 case REACT_STRICT_MODE_TYPE:
6341 fiberTag = Mode;
6342 mode |= StrictMode;
6343 break;
6344 case REACT_CALL_TYPE:
6345 fiberTag = CallComponent;
6346 break;
6347 case REACT_RETURN_TYPE:
6348 fiberTag = ReturnComponent;
6349 break;
6350 default:
6351 {
6352 if (typeof type === 'object' && type !== null) {
6353 switch (type.$$typeof) {
6354 case REACT_PROVIDER_TYPE:
6355 fiberTag = ContextProvider;
6356 break;
6357 case REACT_CONTEXT_TYPE:
6358 // This is a consumer
6359 fiberTag = ContextConsumer;
6360 break;
6361 case REACT_FORWARD_REF_TYPE:
6362 fiberTag = ForwardRef;
6363 break;
6364 default:
6365 if (typeof type.tag === 'number') {
6366 // Currently assumed to be a continuation and therefore is a
6367 // fiber already.
6368 // TODO: The yield system is currently broken for updates in
6369 // some cases. The reified yield stores a fiber, but we don't
6370 // know which fiber that is; the current or a workInProgress?
6371 // When the continuation gets rendered here we don't know if we
6372 // can reuse that fiber or if we need to clone it. There is
6373 // 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