-
Notifications
You must be signed in to change notification settings - Fork 394
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
Hydration flash using loadable-components - Did not expect server HTML to contain a <div> in <div> #135
Comments
loadable-components
- Did not expect server HTML to contain a <div> in <div>
Well I dug into this quite a while before opening the issue and now finally was able to fix it just after. Anyway, this was due to a change needed in And the working code snippet is this:
This issue can be closed. |
Hi @kirkchris I am encountering a flash issue with Thank you ! |
Hi @baptooo I'm not actually sure if this would still be required in v4. v4 is a pretty big update from v3 and we haven't made that upgrade yet. I would check to see if the |
Thank you for your answer @kirkchris yes I figured out that it because I didn't save my Redux store in the No more flash ! 💪 Thank you very much |
Very very nice! Thank you. And yes - still needed with React router 4+. |
I'm not sure you need it. It can happen that we use it different way, but I don't need any workarounds for router only some boilerplate code for loadable-components |
We're not using react-snap nor loadable-components. Just direct import() statements. But it does make sense that the code must be loaded locally on the client before you hydrate in order to prevent flashing. I feel it's more of a subtlety on how React hydrates than anything else. In any case - preloading solved the problem here. |
If you're not using react-snap, than use case is different. For those who use it this is my boilerplate window.snapSaveState = () => getState();
loadComponents()
.then(() => hydrate(App))
.catch(() => render(App)); and don't forget to provide |
Could somebody provide a gist with a full index.js (entry) example? |
Cool, thanks, so fast, yeah! it fails with |
Can you open separate issue, with description of problem. And specify versions of all libraries |
Our app is still experiencing white page flashes when rehydrating from the snapshotted HTML. Originally we believe it was due to not using loadable-components since we had code splitting, but after implementing loadable-components, still seeing the issue.
Here is where we load the app:
The
LoadableComponents.*
are defined like this:Now I've been able to verify that the state is populating correctly into window from loadable-components and it does call the code and say components are loaded prior to running hydrate. When running on dev react throws this warning - and when breakpointing in it appears to throw it on the rootElement, not a nested element:
Did not expect server HTML to contain a <div> in <div>.
I've checked my snapshotted HTML and my fully rendered (via JS) html after the white flash and the contents inside of
rootElement
match exactly. My concern there was something was causing a mismatch leading react not to hydrate appropriately.My guess is that even though the components are done loading via loadable-components, for some reason react is still being rendered once with no content, which is causing the mismatch.
Any ideas for what might cause this? We're using react-router v3.2.0 and react 16.2.0.
The text was updated successfully, but these errors were encountered: