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

Expose initial state in head #446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tornqvist
Copy link
Member

This a 🙋 feature

With the support for Choo SSR using the _experimental_prefetch it would make sense to expose the generated initial state on the window for the client to pick up.

Idk if this is too choo specific to include in the default document but from what I could find no other framework has an official specific key under which to expose the initial state.

Checklist

  • tests pass
  • tests and/or benchmarks are included

Context

This is in part dependent on choojs/choo#639 which ensures a clean state on every call to toString.

Semver Changes

Minor

Copy link
Member

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems good! should we wait for the choo PR to land then?

@yoshuawuyts
Copy link
Member

@tornqvist didn't you mean to reference choojs/choo#638 instead of the components PR. If so, that's been merged and published already!

@tornqvist
Copy link
Member Author

@yoshuawuyts naw, choojs/choo#638 only added lazy stores but never forwarded the new state when reinitializing them on toString, the component PR does this. Also, to prevent leaking state between pages being rendered concurrently (and consequently rendering a bloated initial state) we'd need to change toString to either completely overwrite this.state with what's passed in to toString or merge with the passed in state as base.

@yoshuawuyts
Copy link
Member

@tornqvist ah alright, makes sense!

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

Successfully merging this pull request may close these issues.

3 participants