-
Notifications
You must be signed in to change notification settings - Fork 23
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
Progressive hydration strategy with context #2
Comments
Interesting. Tricky but not impossible. You could try to move the provider inside the ProgressiveHydration component instead. This should enable the context to be available inside the progressive hydrated content as well.
|
@midudev is not possible to share context values between Progressive hydration parts like, for example, for I'm looking for something like: <Layout>
<I18nProvider>
{/* FIRST PROGRESSIVE HYDRATION SECTION */}
<ProgressiveHydration>
<Section1 />
</ProgressiveHydration>
{/* SECOND PROGRESSIVE HYDRATION SECTION */}
<ProgressiveHydration>
<Section2 />
</ProgressiveHydration>
</I18nProvider>
</Layout> Doing this, in this case, is not the solution: <Layout>
{/* FIRST PROGRESSIVE HYDRATION SECTION */}
<ProgressiveHydration>
<I18nProvider>
<Section1 />
</I18nProvider>
</ProgressiveHydration>
{/* SECOND PROGRESSIVE HYDRATION SECTION */}
<ProgressiveHydration>
<I18nProvider>
<Section2 />
</I18nProvider>
</ProgressiveHydration>
</Layout> Here we are duplicating the i18n context in each section. So, is there that limitation doing the |
But, is the solution working? There's no problem duplicating the i18n context provider. In fact, using Context.Provider more than once could be typical for some cases. As it's using internally |
It works in a read-only context as you said. I've put before the example of So duplicating these contexts mean duplicating different state instead of sharing the same. |
Yes, sadly, I would say is a limitation for the strategy as well. :( As you said, duplicating these contexts will create two states for it and thus won't share the same. I will investigate about this limitation in order to try some workaround but, for get this working, more likely some inside ReactDOM work should be done. |
@midudev The same seem to happen with Error:
|
Thanks for the great react rendering strategies - I too am having the issues that @Jeevan-Kishore described above. I tried implementing the work-around that was described here: GoogleChromeLabs/progressive-rendering-frameworks-samples#2 (comment) Unfortunately, I was not successful. @midudev - do you have any suggestions or have you experienced this issue with any of your apps? If so, how did you go about addressing them? |
The progressive hydration strategy doesn't work well with react context, exactly in this scenario:
Result:
The context value is
undefined
after the rehydration...Before hydration:
status: not hydrated yet - context value: example
After hydration:
status: hydrated - context value: undefined
I'm not sure if this can be solved in an easy way or there is some limitation on this strategy. Any idea @midudev ?
The text was updated successfully, but these errors were encountered: