Skip to content

Commit

Permalink
Fix: Restore new Contexts fully in nested render
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Jan 25, 2019
1 parent 59b587c commit 2077600
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ class PartialRenderer extends ReactDOMServerRenderer {
// Restore contexts from new Context API
const {threadID} = this;
this.contextStack = stackState.contexts.map(({context, value}) => {
// Fill any gaps in Context's slots
// (copied from ReactDOM's `validateContextBounds()` function
// https://github.com/facebook/react/blob/f11a9c1cb06514e40a50503e0f9bd26941251e06/packages/react-dom/src/server/ReactPartialRendererContext.js#L55)
for (let i = context._threadCount | 0; i <= threadID; i++) {
context[i] = context._currentValue2;
context._threadCount = i + 1;
}

context[threadID] = value;
return context;
});
Expand Down

0 comments on commit 2077600

Please sign in to comment.