-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Partial support for React.lazy() in server renderer. #16383
Conversation
614453c
to
912e4ef
Compare
Provides partial support for React.lazy() components from the existing PartialRenderer server-side renderer. Lazy components which are already resolved (or rejected), perhaps with something like `react-ssr-prepass`, can be continued into synchronously. If they have not yet been initialized, they'll be initialized before checking, opening the possibility to exploit this capability with a babel transform. If they're pending (which will typically be the case for a just initialized async ctor) then the existing invariant continues to be thrown.
912e4ef
to
c72e37c
Compare
I noticed you removed the |
export function initializeLazyComponentType( | ||
lazyComponent: LazyComponent<any>, | ||
): void { | ||
if (lazyComponent._status === Uninitialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a breaking change if this was using a non-matching version of React. That was the case in React 16.5.0 where this field was called _reactStatus. In this case I that release had lazy behind a feature flag. So iit's probably fine.
We typically are more resilient and check truthy or non-undefined or something like that and then add an expando in that case so that it at least works.
For the enableSuspenseServerRenderer branch, I wasn’t sure of the right behavior or test plan and figured it would be better to keep this one smaller and follow up with that change in another PR after this one |
Provides partial support for React.lazy() components from the existing PartialRenderer server-side renderer. Lazy components which are already resolved (or rejected), perhaps with something like `react-ssr-prepass`, can be continued into synchronously. If they have not yet been initialized, they'll be initialized before checking, opening the possibility to exploit this capability with a babel transform. If they're pending (which will typically be the case for a just initialized async ctor) then the existing invariant continues to be thrown.
Provides partial support for React.lazy() components from the existing PartialRenderer server-side renderer.
Lazy components which are already resolved (or rejected), perhaps with something like
react-ssr-prepass
, can be continued into synchronously. If they have not yet been initialized, they'll be initialized before checking, opening the possibility to exploit this capability with a babel transform. If they're pending (which will typically be the case for a just initialized async ctor) then the existing invariant continues to be thrown.