Skip to content

Commit

Permalink
Clear stack state when lazy node resolved [perf]
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Mar 17, 2019
1 parent 218a763 commit 5640b04
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class PartialRenderer extends ReactDOMServerRenderer {

if (type === TYPE_PROMISE && !node.resolved) {
node.resolved = true;
node.stackState = null;
abort(node.promise);
}

Expand Down Expand Up @@ -404,6 +405,9 @@ class PartialRenderer extends ReactDOMServerRenderer {
this.suspenseNode = node.parentSuspense;
this.restoreStack(node.stackState, element);

// Clear stack state on node
node.stackState = null;

// Render element
this.cycle();

Expand Down Expand Up @@ -441,6 +445,7 @@ class PartialRenderer extends ReactDOMServerRenderer {

// Promise is no longer awaited
node.resolved = true;
node.stackState = null;
this.numAwaiting--;

// Abort all rendering
Expand Down Expand Up @@ -499,6 +504,7 @@ class PartialRenderer extends ReactDOMServerRenderer {
}
} else if (type === TYPE_PROMISE && !node.resolved) {
node.resolved = true;
node.stackState = null;
this.numAwaiting--;
abort(node.promise);
inLazy = true;
Expand Down

0 comments on commit 5640b04

Please sign in to comment.