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

RFC: contextFor #186

Closed
wants to merge 1 commit into from
Closed

Conversation

brandonbloom
Copy link

No description provided.

@gaearon
Copy link
Member

gaearon commented Aug 18, 2021

While the Next.js problem seems hacky, it's hard for me to tell what's fundamental about this. It seems somewhat specific to webpack. Is there a writeup somewhere that explains the technical difficulties in more detail than these source links and this issue? In general, React relies on identity in other ways (e.g. component identity as a "compatible type" reconciliation check). If we use a module system we generally rely on it to provide guarantees. It may be difficult for webpack and/or Next to provide these guarantees, but this doesn't seem to be a problem that needs to be solved at the React level.

@brandonbloom
Copy link
Author

Yeah, even though I wrote this proposal, I'm not convinced that this isn't a Webpack issue. I mostly wrote this to illustrate the problem.

There are also potentially related issues if you do things like render components in a web worker or some other context where something like postMessage is utilized. This necessarily serializes data with the structured clone algorithm, losing reference identity.

These problems may or may not apply to Realms. Search that page for "serialization" and "transfer".

@gaearon
Copy link
Member

gaearon commented Aug 19, 2021

Got it. I think for the normal use case, we can close this, but maybe we can revisit if some other use case comes up. E.g. we do have a remote environment with Server Components (#188). But those will likely necessitate adding some sort of Server Context which itself needs to be serializable. So we'll be drafting that and discussing that separately. If this problem comes up in other scenarios, we should look at them in isolation.

@gaearon gaearon closed this Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants