MCPcopy
hub / github.com/facebook/react / updateElement

Function updateElement

packages/react-reconciler/src/ReactChildFiber.js:559–615  ·  view source on GitHub ↗
(
    returnFiber: Fiber,
    current: Fiber | null,
    element: ReactElement,
    lanes: Lanes,
  )

Source from the content-addressed store, hash-verified

557 }
558
559 function updateElement(
560 returnFiber: Fiber,
561 current: Fiber | null,
562 element: ReactElement,
563 lanes: Lanes,
564 ): Fiber {
565 const elementType = element.type;
566 if (elementType === REACT_FRAGMENT_TYPE) {
567 const updated = updateFragment(
568 returnFiber,
569 current,
570 element.props.children,
571 lanes,
572 element.key,
573 );
574 if (enableFragmentRefs) {
575 coerceRef(updated, element);
576 }
577 validateFragmentProps(element, updated, returnFiber);
578 return updated;
579 }
580 if (current !== null) {
581 if (
582 current.elementType === elementType ||
583 // Keep this check inline so it only runs on the false path:
584 (__DEV__
585 ? isCompatibleFamilyForHotReloading(current, element)
586 : false) ||
587 // Lazy types should reconcile their resolved type.
588 // We need to do this after the Hot Reloading check above,
589 // because hot reloading has different semantics than prod because
590 // it doesn't resuspend. So we can't let the call below suspend.
591 (typeof elementType === 'object' &&
592 elementType !== null &&
593 elementType.$$typeof === REACT_LAZY_TYPE &&
594 resolveLazy(elementType) === current.type)
595 ) {
596 // Move based on index
597 const existing = useFiber(current, element.props);
598 coerceRef(existing, element);
599 existing.return = returnFiber;
600 if (__DEV__) {
601 existing._debugOwner = element._owner;
602 existing._debugInfo = currentDebugInfo;
603 }
604 return existing;
605 }
606 }
607 // Insert
608 const created = createFiberFromElement(element, returnFiber.mode, lanes);
609 coerceRef(created, element);
610 created.return = returnFiber;
611 if (__DEV__) {
612 created._debugInfo = currentDebugInfo;
613 }
614 return created;
615 }
616

Callers 2

updateSlotFunction · 0.85
updateFromMapFunction · 0.85

Calls 7

resolveLazyFunction · 0.90
createFiberFromElementFunction · 0.90
coerceRefFunction · 0.85
useFiberFunction · 0.85
updateFragmentFunction · 0.70
validateFragmentPropsFunction · 0.70

Tested by

no test coverage detected