completeBoundary() — react Function Reference
Architecture documentation for the completeBoundary() function in ReactDOMFizzInstructionSetShared.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD df3bbeff_f8f9_c416_59b7_c39c3f448011["completeBoundary()"] 2a61726f_9a35_9713_662f_bfb1ef81f49f["ReactDOMFizzInstructionSetShared.js"] df3bbeff_f8f9_c416_59b7_c39c3f448011 -->|defined in| 2a61726f_9a35_9713_662f_bfb1ef81f49f style df3bbeff_f8f9_c416_59b7_c39c3f448011 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetShared.js lines 396–449
export function completeBoundary(suspenseBoundaryID, contentID) {
const contentNodeOuter = document.getElementById(contentID);
if (!contentNodeOuter) {
// If the client has failed hydration we may have already deleted the streaming
// segments. The server may also have emitted a complete instruction but cancelled
// the segment. Regardless we can ignore this case.
return;
}
// Find the fallback's first element.
const suspenseIdNodeOuter = document.getElementById(suspenseBoundaryID);
if (!suspenseIdNodeOuter) {
// We'll never reveal this boundary so we can remove its content immediately.
// Otherwise we'll leave it in until we reveal it.
// This is important in case this specific boundary contains other boundaries
// that may get completed before we reveal this one.
contentNodeOuter.parentNode.removeChild(contentNodeOuter);
// The user must have already navigated away from this tree.
// E.g. because the parent was hydrated. That's fine there's nothing to do
// but we have to make sure that we already deleted the container node.
return;
}
// Mark this Suspense boundary as queued so we know not to client render it
// at the end of document load.
const suspenseNodeOuter = suspenseIdNodeOuter.previousSibling;
suspenseNodeOuter.data = SUSPENSE_QUEUED_START_DATA;
// Queue this boundary for the next batch
window['$RB'].push(suspenseIdNodeOuter, contentNodeOuter);
if (window['$RB'].length === 2) {
// This is the first time we've pushed to the batch. We need to schedule a callback
// to flush the batch. This is delayed by the throttle heuristic.
if (typeof window['$RT'] !== 'number') {
// If we haven't had our rAF callback yet, schedule everything for the first paint.
requestAnimationFrame(window['$RV'].bind(null, window['$RB']));
} else {
const currentTime = performance.now();
const msUntilTimeout =
// If the throttle would make us miss the target metric, then shorten the throttle.
// performance.now()'s zero value is assumed to be the start time of the metric.
currentTime < TARGET_VANITY_METRIC &&
currentTime > TARGET_VANITY_METRIC - FALLBACK_THROTTLE_MS
? TARGET_VANITY_METRIC - currentTime
: // Otherwise it's throttled starting from last commit time.
window['$RT'] + FALLBACK_THROTTLE_MS - currentTime;
// We always schedule the flush in a timer even if it's very low or negative to allow
// for multiple completeBoundary calls that are already queued to have a chance to
// make the batch.
setTimeout(window['$RV'].bind(null, window['$RB']), msUntilTimeout);
}
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does completeBoundary() do?
completeBoundary() is a function in the react codebase, defined in packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetShared.js.
Where is completeBoundary() defined?
completeBoundary() is defined in packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetShared.js at line 396.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free