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's permalink option changes form target #27302

Merged
merged 3 commits into from
Aug 29, 2023

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Aug 28, 2023

When the permalink option is passed to useFormState, and the form is submitted before it has hydrated, the permalink will be used as the target of the form action, enabling MPA-style form submissions.

(Note that submitting a form without hydration is a feature of Server Actions; it doesn't work with regular client actions.)

It does not have any effect after the form has hydrated.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Aug 28, 2023
Communicates the intent a bit better
When the `permalink` option is passed to `useFormState`, and the form is
submitted before it has hydrated, the permalink will be used as the target
of the form action, enabling MPA-style form submissions.

(Note that submitting a form without hydration is a feature of Server Actions;
it doesn't work with regular client actions.)

It does not have any effect after the form has hydrated.
@react-sizebot
Copy link

react-sizebot commented Aug 28, 2023

Comparing: 456d153...3216b92

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 = 165.61 kB 165.61 kB = 51.88 kB 51.88 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 174.69 kB 174.69 kB = 54.61 kB 54.61 kB
facebook-www/ReactDOM-prod.classic.js = 570.39 kB 570.39 kB = 100.44 kB 100.44 kB
facebook-www/ReactDOM-prod.modern.js = 554.19 kB 554.19 kB = 97.61 kB 97.61 kB
oss-experimental/react-server/cjs/react-server.development.js +2.45% 150.72 kB 154.42 kB +3.35% 37.46 kB 38.71 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 +2.45% 150.72 kB 154.42 kB +3.35% 37.46 kB 38.71 kB
oss-experimental/react-server/cjs/react-server.production.min.js +0.36% 26.27 kB 26.36 kB +0.62% 8.91 kB 8.96 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +0.21% 64.82 kB 64.95 kB +0.27% 19.57 kB 19.62 kB
oss-experimental/react-dom/cjs/react-dom-static.browser.production.min.js +0.20% 65.10 kB 65.23 kB +0.27% 20.19 kB 20.25 kB
oss-experimental/react-dom/cjs/react-dom-static.edge.production.min.js +0.20% 65.43 kB 65.56 kB +0.26% 20.32 kB 20.38 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js +0.20% 351.36 kB 352.07 kB +0.32% 77.63 kB 77.88 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.min.js +0.20% 65.90 kB 66.03 kB +0.34% 20.31 kB 20.38 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.production.min.js +0.20% 64.98 kB 65.11 kB +0.30% 19.95 kB 20.01 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js +0.20% 355.88 kB 356.59 kB +0.30% 79.83 kB 80.07 kB

Generated by 🚫 dangerJS against 3216b92

// $FlowIgnore[prop-missing]
const metadata: ReactCustomFormAction = boundAction.$$FORM_ACTION(prefix);
// Override the target URL
if (typeof permalink === 'string') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be !== undefined and coerced? Because generally we allow toString/valueOf.

@acdlite acdlite merged commit ddff504 into facebook:main Aug 29, 2023
2 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 29, 2023
When the `permalink` option is passed to `useFormState`, and the form is
submitted before it has hydrated, the permalink will be used as the
target of the form action, enabling MPA-style form submissions.

(Note that submitting a form without hydration is a feature of Server
Actions; it doesn't work with regular client actions.)

It does not have any effect after the form has hydrated.

DiffTrain build for [ddff504](ddff504)
if (__DEV__) {
checkAttributeStringCoercion(permalink, 'target');
}
metadata.target = permalink + '';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be action not target.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

acdlite added a commit that referenced this pull request Aug 30, 2023
I mixed these attributes up in
#27302
github-actions bot pushed a commit that referenced this pull request Aug 30, 2023
I mixed these attributes up in
#27302

DiffTrain build for [2fba484](2fba484)
jerrydev0927 added a commit to jerrydev0927/react that referenced this pull request Jan 5, 2024
I mixed these attributes up in
facebook/react#27302

DiffTrain build for [2fba484cd095ea79b940364cea5107fa4ca9f0c8](facebook/react@2fba484)
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
When the `permalink` option is passed to `useFormState`, and the form is
submitted before it has hydrated, the permalink will be used as the
target of the form action, enabling MPA-style form submissions.

(Note that submitting a form without hydration is a feature of Server
Actions; it doesn't work with regular client actions.)

It does not have any effect after the form has hydrated.
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
When the `permalink` option is passed to `useFormState`, and the form is
submitted before it has hydrated, the permalink will be used as the
target of the form action, enabling MPA-style form submissions.

(Note that submitting a form without hydration is a feature of Server
Actions; it doesn't work with regular client actions.)

It does not have any effect after the form has hydrated.

DiffTrain build for commit ddff504.
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