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

Pass formState directly into createHtmlStream #36

Merged
merged 1 commit into from
Nov 18, 2023

Conversation

unstubbable
Copy link
Owner

@unstubbable unstubbable commented Nov 18, 2023

This avoids the hacky implementation of assigning the form state after server-side rendering has already begun. I believe in the React flight fixture this was only done because RSC rendering and SSR happens in two separate servers. So the form state needed to be extracted from the RSC response stream. Here, we can just pass it around. It seems Next.js is doing that as well (in a more convoluted way, so it's a bit complicated to follow the flow there): https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx

BREAKING CHANGE: The formState now needs to be passed in as part of the options of createHtmlStream.

This avoids the hacky implementation of assigning the form state after server-side rendering has already begun. I believe in the React flight fixture this was only done because RSC rendering and SSR happens in two separate servers. So the form state needed to be extracted from the RSC response stream. Here, we can just pass it around. It seems Next.js is doing that as well (in a more convoluted way, so it's a bit complicated to follow the flow there): https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx

BREAKING CHANGE: The `fomState` now needs to be passed in as part of the options of `createHtmlStream`.
Copy link

vercel bot commented Nov 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mfng ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2023 1:59pm

@unstubbable unstubbable merged commit 1dfa357 into main Nov 18, 2023
5 checks passed
@unstubbable unstubbable deleted the simplify-form-state-handling branch November 18, 2023 14:01
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.

1 participant