Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Bundle collection in window.__INITIAL_STATE__ #92

Closed
thangngoc89 opened this issue Jan 24, 2016 · 3 comments · Fixed by #113
Closed

Bundle collection in window.__INITIAL_STATE__ #92

thangngoc89 opened this issue Jan 24, 2016 · 3 comments · Fixed by #113

Comments

@thangngoc89
Copy link
Contributor

I followed your instruction on create a collection page here

Here is my collection source code

But React will throw a warning:

Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) MgeFRiHrav1TDm192y99 _3jzDdN3QzHnR0O_efk
 (server) MgeFRiHrav1TDm192y99" href="/" data-reac

Demo: http://khoanguyen.me (open your console)

After poking around your code, I see the issue is from this line
https://github.com/MoOx/statinamic/blob/master/src%2Fstatic%2Fto-html%2Furl-as-html.js#L75

Is it posible that we could pass an option to bundle collection in INITIAL_STATE on specific page ?

@MoOx
Copy link
Owner

MoOx commented Jan 24, 2016

I think we have two issues here, so I am going to open a new one for the bug, and keep this one as a feature request.

I already thought about embeding collections directly, but for now I use statinamic on a website with hundreds of posts, so I was thinking that could be better to not include collection in all pages, but well, since user is supposed to only call ONE html pages per session, should be embed.

(The real issue is that rendering collections from json and from node cache does not give the same thing, which lead to a react warning: #96)

@thangngoc89
Copy link
Contributor Author

The real issue is that rendering collections from json and from node cache does not give the same thing, which lead to a react warning

No, there is no different between collections from json and from node cache.
The initial state of collections in client is a blank array []

On a slow connection, you could see the splash between full collection ---> no entry ---> full collection

@MoOx
Copy link
Owner

MoOx commented Jan 24, 2016

Oh right. So I will change this. You are right.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants