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

Function updateHostText

packages/react-reconciler/src/ReactFiberCompleteWork.js:662–689  ·  view source on GitHub ↗
(
  current: Fiber,
  workInProgress: Fiber,
  oldText: string,
  newText: string,
)

Source from the content-addressed store, hash-verified

660}
661
662function updateHostText(
663 current: Fiber,
664 workInProgress: Fiber,
665 oldText: string,
666 newText: string,
667) {
668 if (supportsMutation) {
669 // If the text differs, mark it as an update. All the work in done in commitWork.
670 if (oldText !== newText) {
671 markUpdate(workInProgress);
672 }
673 } else if (supportsPersistence) {
674 if (oldText !== newText) {
675 // If the text content differs, we'll create a new text instance for it.
676 const rootContainerInstance = getRootHostContainer();
677 const currentHostContext = getHostContext();
678 markCloned(workInProgress);
679 workInProgress.stateNode = createTextInstance(
680 newText,
681 rootContainerInstance,
682 currentHostContext,
683 workInProgress,
684 );
685 } else {
686 workInProgress.stateNode = current.stateNode;
687 }
688 }
689}
690
691function cutOffTailIfNeeded(
692 renderState: SuspenseListRenderState,

Callers 1

completeWorkFunction · 0.70

Calls 5

getRootHostContainerFunction · 0.90
getHostContextFunction · 0.90
createTextInstanceFunction · 0.90
markUpdateFunction · 0.85
markClonedFunction · 0.85

Tested by

no test coverage detected