Skip to content

Commit 94f70f5

Browse files
committed
Inline loop
1 parent 781dd45 commit 94f70f5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/react-dom/src/server/ReactPartialRenderer.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ class ReactDOMServerRenderer {
749749
context[threadID] = provider.props.value;
750750
}
751751

752-
popProvider<T>(provider?: ReactProvider<T>): void {
752+
popProvider<T>(provider: ReactProvider<T>): void {
753753
const index = this.contextIndex;
754754
if (__DEV__) {
755755
warningWithoutStack(
@@ -778,12 +778,11 @@ class ReactDOMServerRenderer {
778778
}
779779

780780
clearProviders(): void {
781-
while (this.contextIndex > -1) {
782-
if (__DEV__) {
783-
this.popProvider((this.contextProviderStack: any)[this.contextIndex]);
784-
} else {
785-
this.popProvider();
786-
}
781+
// Restore any remaining providers on the stack to previous values
782+
for (let index = this.contextIndex; index >= 0; index--) {
783+
const context: ReactContext<any> = this.contextStack[index];
784+
const previousValue = this.contextValueStack[index];
785+
context[this.threadID] = previousValue;
787786
}
788787
}
789788

0 commit comments

Comments
 (0)