Commit e19570a
committed
useFormState: Emit comment to mark whether state matches (#27307)
A planned feature of useFormState is that if the page load is the result
of an MPA-style form submission — i.e. a form was submitted before it
was hydrated, using Server Actions — the state of the hook should
transfer to the next page.
I haven't implemented that part yet, but as a prerequisite, we need some
way for Fizz to indicate whether a useFormState hook was rendered using
the "postback" state. That way we can do all state matching logic on the
server without having to replicate it on the client, too.
The approach here is to emit a comment node for each useFormState hook.
We use one of two comment types: `<!--F-->` for a normal useFormState
hook, and `<!--F!-->` for a hook that was rendered using the postback
state. React will read these markers during hydration. This is similar
to how we encode Suspense boundaries.
Again, the actual matching algorithm is not yet implemented — for now,
the "not matching" marker is always emitted.
We can optimize this further by not emitting any markers for a render
that is not the result of a form postback, which I'll do in subsequent
PRs.
DiffTrain build for commit 8b26f07.1 parent d6a6e06 commit e19570a
File tree
7 files changed
+9
-9
lines changed- compiled-rn/facebook-fbsource/xplat/js
- RKJSModules/vendor
- react-test-renderer/cjs
- react/cjs
- react-native-github/Libraries/Renderer
7 files changed
+9
-9
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23994 | 23994 | | |
23995 | 23995 | | |
23996 | 23996 | | |
23997 | | - | |
| 23997 | + | |
23998 | 23998 | | |
23999 | 23999 | | |
24000 | 24000 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8617 | 8617 | | |
8618 | 8618 | | |
8619 | 8619 | | |
8620 | | - | |
| 8620 | + | |
8621 | 8621 | | |
8622 | 8622 | | |
8623 | 8623 | | |
| |||
8648 | 8648 | | |
8649 | 8649 | | |
8650 | 8650 | | |
8651 | | - | |
| 8651 | + | |
8652 | 8652 | | |
8653 | 8653 | | |
8654 | 8654 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9043 | 9043 | | |
9044 | 9044 | | |
9045 | 9045 | | |
9046 | | - | |
| 9046 | + | |
9047 | 9047 | | |
9048 | 9048 | | |
9049 | 9049 | | |
| |||
9074 | 9074 | | |
9075 | 9075 | | |
9076 | 9076 | | |
9077 | | - | |
| 9077 | + | |
9078 | 9078 | | |
9079 | 9079 | | |
9080 | 9080 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
619 | | - | |
| 619 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
622 | | - | |
| 622 | + | |
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments