Failing test for Context bug in ReactPartialRenderer#12974
Failing test for Context bug in ReactPartialRenderer#12974aweary wants to merge 1 commit intofacebook:masterfrom
Conversation
What do you mean by "doesn't have a value"? |
@gaearon I mean when a Provider doesn't have a |
|
If Provider doesn't have a value prop then you'll get undefined. The |
|
@gaearon sure, but it sets The only place I see react/packages/react-dom/src/server/ReactPartialRenderer.js Lines 692 to 694 in 36546b5 So I'm not sure how setting it to |
|
Closing in favor of #12985 |
A failing test for the bug reported in #12968
A summary of the issue is that rendering this combination of consumers and providers for multiple contexts causes a bug where the value from one context is being used in the other in subsequent renders.
This is possible because context is stored on the Context element itself, so it's mutated as the components are rendered. In this case, the wrong value is being set on a provider when its being popped:
react/packages/react-dom/src/server/ReactPartialRenderer.js
Lines 692 to 700 in 36546b5
previousProviderends up being the provider for the other context, so the next time it renders it has the wrong value. The assumption that the context type is correct because of the index check isn't accurate. It's also strange that it's always setting the context value topreviousProvider.props.value, even if the provider doesn't have a value.Not sure what the right fix is, but I'd like to figure it out 😄
cc @acdlite @gaearon