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

useFormState: MPA submissions to a different page #27372

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Sep 14, 2023

The permalink option of useFormState controls which page the form is submitted to during an MPA form submission (i.e. a submission that happens before hydration, or when JS is disabled). If the same useFormState appears on the resulting page, and the permalink option matches, it should receive the form state from the submission despite the fact that the keypaths do not match.

So the logic for whether a form state instance is considered a match is:

  • Both instances must be passed the same action signature
  • If a permalink is provided, the permalinks must match.
  • If a permalink is not provided, the keypaths must match.

Currently, if there are multiple matching useFormStates, they will all match and receive the form state. We should probably only match the first one, and/or warn when this happens. I've left this as a TODO for now, pending further discussion.

The permalink option of useFormState controls which page the form is
submitted to during an MPA form submission (i.e. a submission that
happens before hydration, or when JS is disabled). If the same
useFormState appears on the resulting page, and the permalink option
matches, it should receive the form state from the submission despite
the fact that the keypaths do not match.

So the logic for whether a form state instance is considered a match is:
- Both instances must be passed the same action signature
- If a permalink is provided, the permalinks must match.
- If a permalink is not provided, the keypaths must match.

Currently, if there are multiple matching useFormStates, they will all
match and receive the form state. We should probably only match the
first one, and/or warn when this happens. I've left this as a TODO for
now, pending further discussion.
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Sep 14, 2023
@react-sizebot
Copy link

Comparing: 95c9554...a3e39ce

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 166.62 kB 166.62 kB = 52.13 kB 52.13 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 176.05 kB 176.05 kB = 54.97 kB 54.96 kB
facebook-www/ReactDOM-prod.classic.js = 571.73 kB 571.73 kB = 100.64 kB 100.64 kB
facebook-www/ReactDOM-prod.modern.js = 555.46 kB 555.46 kB = 97.75 kB 97.75 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-server/cjs/react-server.development.js +0.56% 169.38 kB 170.32 kB +0.55% 41.60 kB 41.83 kB
oss-experimental/react-server/cjs/react-server.production.min.js +0.32% 29.88 kB 29.98 kB +0.32% 9.90 kB 9.93 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js +0.29% 350.94 kB 351.97 kB +0.33% 78.21 kB 78.46 kB
facebook-www/ReactDOMServer-dev.modern.js +0.29% 355.75 kB 356.78 kB +0.32% 79.36 kB 79.61 kB
facebook-www/ReactDOMServer-dev.classic.js +0.28% 363.17 kB 364.20 kB +0.31% 81.00 kB 81.25 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js +0.26% 360.59 kB 361.53 kB +0.27% 81.39 kB 81.60 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.26% 363.09 kB 364.03 kB +0.27% 81.82 kB 82.04 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.development.js +0.26% 380.51 kB 381.49 kB +0.27% 82.68 kB 82.91 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js +0.26% 365.00 kB 365.94 kB +0.26% 82.27 kB 82.49 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js +0.25% 369.22 kB 370.16 kB +0.26% 82.55 kB 82.76 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.development.js +0.25% 369.63 kB 370.57 kB +0.26% 82.67 kB 82.89 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js +0.25% 370.51 kB 371.45 kB +0.26% 82.87 kB 83.08 kB
oss-experimental/react-dom/umd/react-dom-server.browser.development.js +0.25% 386.93 kB 387.91 kB +0.25% 83.44 kB 83.65 kB
facebook-www/ReactDOMServer-prod.modern.js +0.24% 157.61 kB 157.99 kB +0.15% 28.78 kB 28.83 kB
facebook-www/ReactDOMServer-prod.classic.js +0.24% 158.28 kB 158.66 kB +0.13% 28.98 kB 29.02 kB
facebook-www/ReactDOMServerStreaming-prod.modern.js +0.24% 159.70 kB 160.09 kB +0.15% 29.73 kB 29.77 kB

Generated by 🚫 dangerJS against a3e39ce

@sebmarkbage
Copy link
Collaborator

Maybe permalink isn't the quite the right terminology for this although it's usually the same thing but it doesn't have to be a permanent link or even easily consumable. Maybe canonicalURL (like <link rel="canonical">) is also somewhat similar. It really means a URL that represents this form in isolation (and not in a list or in an expansion/fly out).

@acdlite acdlite merged commit caa716d into facebook:main Sep 14, 2023
36 checks passed
github-actions bot pushed a commit that referenced this pull request Sep 14, 2023
The permalink option of useFormState controls which page the form is
submitted to during an MPA form submission (i.e. a submission that
happens before hydration, or when JS is disabled). If the same
useFormState appears on the resulting page, and the permalink option
matches, it should receive the form state from the submission despite
the fact that the keypaths do not match.

So the logic for whether a form state instance is considered a match is:
- Both instances must be passed the same action signature
- If a permalink is provided, the permalinks must match.
- If a permalink is not provided, the keypaths must match.

Currently, if there are multiple matching useFormStates, they will all
match and receive the form state. We should probably only match the
first one, and/or warn when this happens. I've left this as a TODO for
now, pending further discussion.

DiffTrain build for [caa716d](caa716d)
shuding added a commit to vercel/next.js that referenced this pull request Oct 3, 2023
Ref: facebook/react#27372.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
The permalink option of useFormState controls which page the form is
submitted to during an MPA form submission (i.e. a submission that
happens before hydration, or when JS is disabled). If the same
useFormState appears on the resulting page, and the permalink option
matches, it should receive the form state from the submission despite
the fact that the keypaths do not match.

So the logic for whether a form state instance is considered a match is:
- Both instances must be passed the same action signature
- If a permalink is provided, the permalinks must match.
- If a permalink is not provided, the keypaths must match.

Currently, if there are multiple matching useFormStates, they will all
match and receive the form state. We should probably only match the
first one, and/or warn when this happens. I've left this as a TODO for
now, pending further discussion.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
The permalink option of useFormState controls which page the form is
submitted to during an MPA form submission (i.e. a submission that
happens before hydration, or when JS is disabled). If the same
useFormState appears on the resulting page, and the permalink option
matches, it should receive the form state from the submission despite
the fact that the keypaths do not match.

So the logic for whether a form state instance is considered a match is:
- Both instances must be passed the same action signature
- If a permalink is provided, the permalinks must match.
- If a permalink is not provided, the keypaths must match.

Currently, if there are multiple matching useFormStates, they will all
match and receive the form state. We should probably only match the
first one, and/or warn when this happens. I've left this as a TODO for
now, pending further discussion.

DiffTrain build for commit caa716d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants