( type: any, // React$ElementType key: null | string, pendingProps: any, owner: null | ReactComponentInfo | Fiber, mode: TypeOfMode, lanes: Lanes, )
| 544 | |
| 545 | // TODO: Get rid of this helper. Only createFiberFromElement should exist. |
| 546 | export function createFiberFromTypeAndProps( |
| 547 | type: any, // React$ElementType |
| 548 | key: null | string, |
| 549 | pendingProps: any, |
| 550 | owner: null | ReactComponentInfo | Fiber, |
| 551 | mode: TypeOfMode, |
| 552 | lanes: Lanes, |
| 553 | ): Fiber { |
| 554 | let fiberTag: WorkTag = FunctionComponent; |
| 555 | // The resolved type is set if we know what the final type will be. I.e. it's not lazy. |
| 556 | let resolvedType = type; |
| 557 | if (typeof type === 'function') { |
| 558 | if (shouldConstruct(type)) { |
| 559 | fiberTag = ClassComponent; |
| 560 | if (__DEV__) { |
| 561 | resolvedType = resolveClassForHotReloading(resolvedType); |
| 562 | } |
| 563 | } else { |
| 564 | if (__DEV__) { |
| 565 | resolvedType = resolveFunctionForHotReloading(resolvedType); |
| 566 | } |
| 567 | } |
| 568 | } else if (typeof type === 'string') { |
| 569 | if (supportsResources && supportsSingletons) { |
| 570 | const hostContext = getHostContext(); |
| 571 | fiberTag = isHostHoistableType(type, pendingProps, hostContext) |
| 572 | ? HostHoistable |
| 573 | : isHostSingletonType(type) |
| 574 | ? HostSingleton |
| 575 | : HostComponent; |
| 576 | } else if (supportsResources) { |
| 577 | const hostContext = getHostContext(); |
| 578 | fiberTag = isHostHoistableType(type, pendingProps, hostContext) |
| 579 | ? HostHoistable |
| 580 | : HostComponent; |
| 581 | } else if (supportsSingletons) { |
| 582 | fiberTag = isHostSingletonType(type) ? HostSingleton : HostComponent; |
| 583 | } else { |
| 584 | fiberTag = HostComponent; |
| 585 | } |
| 586 | } else { |
| 587 | getTag: switch (type) { |
| 588 | case REACT_ACTIVITY_TYPE: |
| 589 | return createFiberFromActivity(pendingProps, mode, lanes, key); |
| 590 | case REACT_FRAGMENT_TYPE: |
| 591 | return createFiberFromFragment(pendingProps.children, mode, lanes, key); |
| 592 | case REACT_STRICT_MODE_TYPE: |
| 593 | fiberTag = Mode; |
| 594 | mode |= StrictLegacyMode; |
| 595 | if (disableLegacyMode || (mode & ConcurrentMode) !== NoMode) { |
| 596 | // Strict effects should never run on legacy roots |
| 597 | mode |= StrictEffectsMode; |
| 598 | } |
| 599 | break; |
| 600 | case REACT_PROFILER_TYPE: |
| 601 | return createFiberFromProfiler(pendingProps, mode, lanes, key); |
| 602 | case REACT_SUSPENSE_TYPE: |
| 603 | return createFiberFromSuspense(pendingProps, mode, lanes, key); |
no test coverage detected