recursivelyInsertClonesFromExistingTree() — react Function Reference
Architecture documentation for the recursivelyInsertClonesFromExistingTree() function in ReactFiberApplyGesture.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD d5ea8670_901e_392b_55a7_640c298b5971["recursivelyInsertClonesFromExistingTree()"] ee850b36_fc0b_9bb2_5b69_58d705aef9a5["ReactFiberApplyGesture.js"] d5ea8670_901e_392b_55a7_640c298b5971 -->|defined in| ee850b36_fc0b_9bb2_5b69_58d705aef9a5 5da5a209_accd_7ea4_eb0a_748553ba2647["recursivelyInsertClones()"] 5da5a209_accd_7ea4_eb0a_748553ba2647 -->|calls| d5ea8670_901e_392b_55a7_640c298b5971 c1429200_7c6a_e13e_08a2_fa616dd968a7["trackHostMutation()"] d5ea8670_901e_392b_55a7_640c298b5971 -->|calls| c1429200_7c6a_e13e_08a2_fa616dd968a7 10ff51a0_caf4_3442_72f9_fbea3bdcc8bc["pushMutationContext()"] d5ea8670_901e_392b_55a7_640c298b5971 -->|calls| 10ff51a0_caf4_3442_72f9_fbea3bdcc8bc e901b09e_6606_f374_768c_8c36e1bb4676["applyExitViewTransition()"] d5ea8670_901e_392b_55a7_640c298b5971 -->|calls| e901b09e_6606_f374_768c_8c36e1bb4676 4d7237b6_d6aa_66af_1ea0_e984a1cd77c4["applyAppearingPairViewTransition()"] d5ea8670_901e_392b_55a7_640c298b5971 -->|calls| 4d7237b6_d6aa_66af_1ea0_e984a1cd77c4 3d076554_3975_745b_8cf0_95fb957dfe27["applyNestedViewTransition()"] d5ea8670_901e_392b_55a7_640c298b5971 -->|calls| 3d076554_3975_745b_8cf0_95fb957dfe27 e85c52cb_0e14_c3e5_2d41_fe535fe1ddf7["popMutationContext()"] d5ea8670_901e_392b_55a7_640c298b5971 -->|calls| e85c52cb_0e14_c3e5_2d41_fe535fe1ddf7 style d5ea8670_901e_392b_55a7_640c298b5971 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-reconciler/src/ReactFiberApplyGesture.js lines 582–738
function recursivelyInsertClonesFromExistingTree(
parentFiber: Fiber,
hostParentClone: Instance,
parentViewTransition: null | ViewTransitionState,
visitPhase: VisitPhase,
): void {
let child = parentFiber.child;
while (child !== null) {
switch (child.tag) {
case HostComponent: {
const instance: Instance = child.stateNode;
let nextPhase: VisitPhase;
switch (visitPhase) {
case CLONE_EXIT:
case CLONE_UNHIDE:
case CLONE_APPEARING_PAIR:
// If this was an unhide, we need to keep going if there are any named
// pairs in this subtree, since they might need to be marked.
nextPhase =
(child.subtreeFlags & ViewTransitionNamedStatic) !== NoFlags
? CLONE_APPEARING_PAIR
: CLONE_UNCHANGED;
break;
default:
// We've found any "layout" View Transitions at this point so we can bail.
nextPhase = CLONE_UNCHANGED;
}
let clone: Instance;
if (nextPhase !== CLONE_UNCHANGED) {
// We might need a handle on these clones, so we need to do a shallow clone
// and keep going.
clone = cloneMutableInstance(instance, false);
recursivelyInsertClonesFromExistingTree(
child,
clone,
null,
nextPhase,
);
} else {
// If we have no mutations in this subtree, and we don't need a handle on the
// clones, then we can do a deep clone instead and bailout.
clone = cloneMutableInstance(instance, true);
// TODO: We may need to transfer some DOM state such as scroll position
// for the deep clones.
// TODO: If there's a manual view-transition-name inside the clone we
// should ideally remove it from the original and then restore it in mutation
// phase. Otherwise it leads to duplicate names.
}
appendChild(hostParentClone, clone);
if (parentViewTransition !== null) {
if (parentViewTransition.clones === null) {
parentViewTransition.clones = [clone];
} else {
parentViewTransition.clones.push(clone);
}
}
if (visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE) {
unhideInstance(clone, child.memoizedProps);
trackHostMutation();
}
break;
}
case HostText: {
const textInstance: TextInstance = child.stateNode;
if (textInstance === null) {
throw new Error(
'This should have a text node initialized. This error is likely ' +
'caused by a bug in React. Please file an issue.',
);
}
const clone = cloneMutableTextInstance(textInstance);
appendChild(hostParentClone, clone);
if (visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE) {
unhideTextInstance(clone, child.memoizedProps);
trackHostMutation();
}
break;
}
case HostPortal: {
// TODO: Consider what should happen to Portals. For now we exclude them.
break;
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does recursivelyInsertClonesFromExistingTree() do?
recursivelyInsertClonesFromExistingTree() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberApplyGesture.js.
Where is recursivelyInsertClonesFromExistingTree() defined?
recursivelyInsertClonesFromExistingTree() is defined in packages/react-reconciler/src/ReactFiberApplyGesture.js at line 582.
What does recursivelyInsertClonesFromExistingTree() call?
recursivelyInsertClonesFromExistingTree() calls 6 function(s): applyAppearingPairViewTransition, applyExitViewTransition, applyNestedViewTransition, popMutationContext, pushMutationContext, trackHostMutation.
What calls recursivelyInsertClonesFromExistingTree()?
recursivelyInsertClonesFromExistingTree() is called by 1 function(s): recursivelyInsertClones.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free