remountFiber() — react Function Reference
Architecture documentation for the remountFiber() function in ReactFiberBeginWork.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD b4e6b9a2_baf8_7349_8a18_89866b36cc91["remountFiber()"] 0be70812_cc0c_b210_f84f_8e61dd5f831c["ReactFiberBeginWork.js"] b4e6b9a2_baf8_7349_8a18_89866b36cc91 -->|defined in| 0be70812_cc0c_b210_f84f_8e61dd5f831c 235e1db1_02a4_912f_7d82_ea6636c850c0["beginWork()"] 235e1db1_02a4_912f_7d82_ea6636c850c0 -->|calls| b4e6b9a2_baf8_7349_8a18_89866b36cc91 style b4e6b9a2_baf8_7349_8a18_89866b36cc91 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-reconciler/src/ReactFiberBeginWork.js lines 3803–3872
function remountFiber(
current: Fiber,
oldWorkInProgress: Fiber,
newWorkInProgress: Fiber,
): Fiber | null {
if (__DEV__) {
const returnFiber = oldWorkInProgress.return;
if (returnFiber === null) {
// eslint-disable-next-line react-internal/prod-error-codes
throw new Error('Cannot swap the root fiber.');
}
// Disconnect from the old current.
// It will get deleted.
current.alternate = null;
oldWorkInProgress.alternate = null;
// Connect to the new tree.
newWorkInProgress.index = oldWorkInProgress.index;
newWorkInProgress.sibling = oldWorkInProgress.sibling;
newWorkInProgress.return = oldWorkInProgress.return;
newWorkInProgress.ref = oldWorkInProgress.ref;
if (__DEV__) {
newWorkInProgress._debugInfo = oldWorkInProgress._debugInfo;
}
// Replace the child/sibling pointers above it.
if (oldWorkInProgress === returnFiber.child) {
returnFiber.child = newWorkInProgress;
} else {
let prevSibling = returnFiber.child;
if (prevSibling === null) {
// eslint-disable-next-line react-internal/prod-error-codes
throw new Error('Expected parent to have a child.');
}
// $FlowFixMe[incompatible-use] found when upgrading Flow
while (prevSibling.sibling !== oldWorkInProgress) {
// $FlowFixMe[incompatible-use] found when upgrading Flow
prevSibling = prevSibling.sibling;
if (prevSibling === null) {
// eslint-disable-next-line react-internal/prod-error-codes
throw new Error('Expected to find the previous sibling.');
}
}
// $FlowFixMe[incompatible-use] found when upgrading Flow
prevSibling.sibling = newWorkInProgress;
}
// Delete the old fiber and place the new one.
// Since the old fiber is disconnected, we have to schedule it manually.
const deletions = returnFiber.deletions;
if (deletions === null) {
returnFiber.deletions = [current];
returnFiber.flags |= ChildDeletion;
} else {
deletions.push(current);
}
newWorkInProgress.flags |= Placement;
// Restart work from the new fiber.
return newWorkInProgress;
} else {
throw new Error(
'Did not expect this call in production. ' +
'This is a bug in React. Please file an issue.',
);
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does remountFiber() do?
remountFiber() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberBeginWork.js.
Where is remountFiber() defined?
remountFiber() is defined in packages/react-reconciler/src/ReactFiberBeginWork.js at line 3803.
What calls remountFiber()?
remountFiber() is called by 1 function(s): beginWork.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free