Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context works strange in 16.6.3 in renderToStaticMarkup #14287

Closed
konstantin24121 opened this issue Nov 20, 2018 · 3 comments
Closed

Context works strange in 16.6.3 in renderToStaticMarkup #14287

konstantin24121 opened this issue Nov 20, 2018 · 3 comments

Comments

@konstantin24121
Copy link

Do you want to request a feature or report a bug?

bug or unexpected behavior

What is the current behavior?

In version react-dom@16.6.1 I used Context.Consumer in renderToStaticMarkup and it works fine if a call it, but in react-dom@16.6.3 Context.Consumer lose Context.Provider. To be precise Consumer loses only new values passed to Provider, default values work fine in all cases.

Example below:

with react-dom@16.6.1 - https://codesandbox.io/s/0movl04pyw
with react-dom@16.6.3 - https://codesandbox.io/s/6j39m60j9n

What is the expected behavior?

Context.Consumer don't lose a context passed with Context.Provider.
Maybe the example is wrong and there is another way to render Context.Consumer's components into a string?

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
In react-dom@16.6.1 - works fine
In react-dom@16.6.3 - context losed

@aweary
Copy link
Contributor

aweary commented Nov 20, 2018

Seems related to #14182 (comment)

@konstantin24121 konstantin24121 changed the title Context works strange in 16.6.3 Context works strange in 16.6.3 in renderToStaticMarkup Nov 20, 2018
@gaearon
Copy link
Collaborator

gaearon commented Nov 20, 2018

Context shouldn't propagate through renderToStaticMarkup / renderToString calls. Unfortunately that was a bug in the original release which got fixed in 16.6.3. While I understand in your case you might have expected it to work, but it's just as likely that it could cause product bugs (in case you're rendering <Something /> that's meant to be isolated and it picks up the wrong context from above).

The use case itself is interesting and potentially legit. I'll create a separate issue to track it.

@gaearon
Copy link
Collaborator

gaearon commented Nov 20, 2018

Filed #14292 to track it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants