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

Avoid useless initialState for static data. #47

Open
cbilotta opened this issue Apr 14, 2017 · 0 comments
Open

Avoid useless initialState for static data. #47

cbilotta opened this issue Apr 14, 2017 · 0 comments
Milestone

Comments

@cbilotta
Copy link
Member

On SSR, you sometime have to fill the store with data that has the only purpose of making the rendering of static HTML possible.

For example, if you want to render a static blogpost, you need to load the blogpost into the initial state, and then you basically have duplication of data between the store and the HTML sent to the client.

One solution to this could be to put an HOC around this block of static HTML that would, on mount in the client, take the innerHTML of it's children, and put it in the store, so for future re-renders, the needed data is actually in the store.

On the server, due to the way we walk the tree, we can easily delete this data from the initialStore and avoid sending it to the client.

This way, we could save precious bytes in the initial HTML payload.

@cbilotta cbilotta added this to the 4.0.0 milestone Apr 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant