-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
unstable_renderSubtreeIntoContainer does not transfer context #16721
Comments
This API is on its way to being deprecated and deleted. Portals are the intended alternative. As a legacy API that was never stable, it’s not expected to support new features like modern Context. |
Also faced with this problem during upgrade of legacy code base from react 15 to latest react 16. We depend on material ui v0 which have utility component RenderToLayer which is implemented on top of |
As I mentioned before, |
Yep, thanks for quick reply, Dan. Here is almost working replacement for |
@gaearon: Any kind of feedback would be appreciated on the issue @fedulovivan mentioned. The last response we got from any React contributor was way back in 2018, and all the workarounds we've come up with are still problematic 😐 |
@mogelbrod I don't currently have anything to add to that, but something like this (#11387 (comment)) seems reasonable to me if you're migrating an existing component. |
Thanks for the quick response! Pointing out some notable issues with that workaround:
Is the best bet for us to stay on the lookout for issues/PRs related to portals/ A solution that works in "all" cases is obviously what the people in the thread are striving for. Unfortunately it doesn't look to be possible with the current React API, so the next best thing would be some insight into if any changes are being considered, so we can adapt accordingly. Of course no single person (you or any other individual) owes us a response, but the current situation results a sense of hopelessness (at least for me). |
Thanks for the context about workaround. Since you already have that domain knowledge, the best next step is probably to write an RFC for the behavior you want and the alternatives you considered: https://github.com/reactjs/rfcs. Keep in mind that an RFC saying "let's just change this" is unlikely to be helpful. Writing a good RFC requires both understanding of why we have the current behavior, and a plan to change it in a way that suits your use cases without regressing on others. Regardless of that, |
@gaearon Thanks for the clear response and suggestion, it's very appreciated! An RFC definitely sounds lake the logical approach - I'll continue the discussion in the original issue 👍 |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
unstable_renderSubtreeIntoContainer
does not inherit the context from its current tree and transfer it to the rendered subtreeIf the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
https://codesandbox.io/s/portal-context-propagation-169-jid1w
What is the expected behavior?
the second set of text should also be red
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React v16+
The text was updated successfully, but these errors were encountered: