Skip to content

Proposal: Hydrate #223

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

Open
MartinKavik opened this issue Sep 19, 2019 · 0 comments
Open

Proposal: Hydrate #223

MartinKavik opened this issue Sep 19, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@MartinKavik
Copy link
Member

Motivation

Flashing page elements on wasm file load on prerendered pages.

How to reproduce

Try to open kavik.cz/about/ on a mobile or in a desktop browser with enabled throttling in dev tools. The first you see prerendered html and once the wasm is loaded, the entire page is rerendered which causes flashes.

Problem

This code: https://github.com/MartinKavik/kavik.cz/blob/master/crate/src/app.rs#L49. I have to delete root element content before render, otherwise Seed will append identical html at the end of the root.

How to resolve

Use prerendered HTML as the previously rendered HTML by Seed. So either introduce a new function hydrate or make render more intelligent (probably better option). There are examples from other frameworks: https://github.com/stereobooster/react-snap#basic-usage-with-create-react-app.

Possible implementation problems

Prerendered and rendered code isn't 100% identical, e.g. hamburger is spinner in prerendered version (see my example in section how to reproduce).

Public API changes.

None, if we update render function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants