Repository: facebook/react
File: packages/react-reconciler/src/ReactFiberCommitViewTransitions.js (JavaScript)

Code before:
  restoreViewTransitionOnHostInstances(current.child, true);
  restoreViewTransitionOnHostInstances(finishedWork.child, true);
}

export function restoreUpdateViewTransitionForGesture(
  current: Fiber,
  finishedWork: Fiber,
): void {
  // For gestures we don't need to reset "finishedWork" because those would
  // have all been clones that got deleted.
  restoreViewTransitionOnHostInstances(current.child, true);
}

export function restoreNestedViewTransitions(changedParent: Fiber): void {
  let child = changedParent.child;
  while (child !== null) {
    if (child.tag === ViewTransitionComponent) {
      restoreViewTransitionOnHostInstances(child.child, false);
    } else if ((child.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
      restoreNestedViewTransitions(child);
    }
    child = child.sibling;
  }
}

export function cancelViewTransitionHostInstances(
  child: null | Fiber,
  oldName: string,
  stopAtNestedViewTransitions: boolean,
): void {
  viewTransitionHostInstanceIdx = 0;
  cancelViewTransitionHostInstancesRecursive(
    child,
    oldName,
    stopAtNestedViewTransitions,
  );
}

function cancelViewTransitionHostInstancesRecursive(
  child: null | Fiber,
  oldName: string,
  stopAtNestedViewTransitions: boolean,
): void {
  if (!supportsMutation) {
    return;
  }
  while (child !== null) {
    if (child.tag === HostComponent) {
      const instance: Instance = child.stateNode;
      if (viewTransitionCancelableChildren === null) {
        viewTransitionCancelableChildren = [];

Review comment (refactor):
This helper was only used when layout was "none" but update was not. If both were "none" we don't apply the names in the first place. Which is what happens if just update is "none" now and this case is not expressible.

Code after:
export function restoreUpdateViewTransitionForGesture(
  current: Fiber,
  finishedWork: Fiber,
): void {
  // For gestures we don't need to reset "finishedWork" because those would
  // have all been clones that got deleted.
  restoreViewTransitionOnHostInstances(current.child, true);
}

export function restoreNestedViewTransitions(changedParent: Fiber): void {
  let child = changedParent.child;
  while (child !== null) {
    if (child.tag === ViewTransitionComponent) {
      restoreViewTransitionOnHostInstances(child.child, false);
    } else if ((child.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
      restoreNestedViewTransitions(child);
    }
    child = child.sibling;
  }
}

export function measureViewTransitionHostInstances(
  parentViewTransition: Fiber,
  child: null | Fiber,
  newName: string,
  oldName: string,
  className: ?string,
  previousMeasurements: null | Array<InstanceMeasurement>,
  stopAtNestedViewTransitions: boolean,
): boolean {
  viewTransitionHostInstanceIdx = 0;
  return measureViewTransitionHostInstancesRecursive(
    parentViewTransition,
    child,
    newName,
    oldName,
    className,
    previousMeasurements,
    stopAtNestedViewTransitions,
  );
}

function measureViewTransitionHostInstancesRecursive(
  parentViewTransition: Fiber,
  child: null | Fiber,
  newName: string,
  oldName: string,
  className: ?string,
  previousMeasurements: null | Array<InstanceMeasurement>,
  stopAtNestedViewTransitions: boolean,
): boolean {