Skip to content

Expose initial state in head - #446

Open
tornqvist wants to merge 1 commit into
choojs:masterfrom
tornqvist:expose-initial-state
Open

Expose initial state in head#446
tornqvist wants to merge 1 commit into
choojs:masterfrom
tornqvist:expose-initial-state

Conversation

@tornqvist

Copy link
Copy Markdown
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

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

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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