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

[Flight] Progressively Enhanced Server Actions #26774

Merged
merged 4 commits into from
May 3, 2023

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented May 3, 2023

This automatically exposes $$FORM_ACTION on Server References coming from Flight. So that when they're used in a form action, we can encode the ID for the server reference as a hidden field or as part of the name of a button.

If the Server Action is a bound function it can have complex data associated with it. In this case this additional data is encoded as additional form fields.

To process a POST on the server there's now a decodeAction helper that can take one of these progressive posts from FormData and give you a function that is prebound with the correct closure and FormData so that you can just invoke it.

I updated the fixture which now has a "Server State" that gets automatically refreshed. This also lets us visualize form fields. There's no "Action State" here for showing error messages that are not thrown, that's still up to user space.

decodeAction lets you take a form that was posted back to the server and
automatically decode the first action's server reference and its bound
arguments.

We must wait to fill up the FormData since we're going to pass them all as
arguments to the action and we don't know how many there will be.
This uses an in-memory Server State that gets mutated and then the RSC
payload is refreshed after a mutation takes place.
@sebmarkbage sebmarkbage requested review from gnoff and acdlite May 3, 2023 22:18
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels May 3, 2023
@react-sizebot
Copy link

react-sizebot commented May 3, 2023

Comparing: c10010a...249f02a

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 = 164.19 kB 164.19 kB = 51.78 kB 51.78 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 171.55 kB 171.55 kB = 53.98 kB 53.98 kB
facebook-www/ReactDOM-prod.classic.js = 570.13 kB 570.13 kB = 100.62 kB 100.62 kB
facebook-www/ReactDOM-prod.modern.js = 553.87 kB 553.87 kB = 97.80 kB 97.80 kB
facebook-relay/flight/ReactFlightNativeRelayClient-dev.js +106.88% 20.82 kB 43.08 kB +95.82% 5.43 kB 10.64 kB
facebook-www/ReactFlightDOMRelayClient-dev.classic.js +98.12% 22.50 kB 44.58 kB +89.99% 5.65 kB 10.74 kB
facebook-www/ReactFlightDOMRelayClient-dev.modern.js +98.12% 22.50 kB 44.58 kB +89.99% 5.65 kB 10.74 kB
oss-experimental/react-client/cjs/react-client-flight.development.js +93.21% 23.15 kB 44.73 kB +84.36% 6.11 kB 11.27 kB
oss-stable-semver/react-client/cjs/react-client-flight.development.js +93.21% 23.15 kB 44.73 kB +84.36% 6.11 kB 11.27 kB
oss-stable/react-client/cjs/react-client-flight.development.js +93.21% 23.15 kB 44.73 kB +84.36% 6.11 kB 11.27 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +81.10% 26.61 kB 48.19 kB +75.69% 6.80 kB 11.94 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +81.10% 26.61 kB 48.19 kB +75.69% 6.80 kB 11.94 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +81.10% 26.61 kB 48.19 kB +75.69% 6.80 kB 11.94 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +76.68% 28.14 kB 49.72 kB +71.23% 7.24 kB 12.39 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +76.68% 28.14 kB 49.72 kB +71.23% 7.24 kB 12.39 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +76.68% 28.14 kB 49.72 kB +71.23% 7.24 kB 12.39 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +76.09% 28.36 kB 49.94 kB +70.34% 7.32 kB 12.47 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +76.09% 28.36 kB 49.94 kB +70.34% 7.32 kB 12.47 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +76.09% 28.36 kB 49.94 kB +70.34% 7.32 kB 12.47 kB
facebook-relay/flight/ReactFlightNativeRelayClient-prod.js +38.80% 12.46 kB 17.30 kB +38.07% 3.23 kB 4.45 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +35.83% 7.13 kB 9.68 kB +34.56% 2.83 kB 3.80 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +35.83% 7.13 kB 9.68 kB +34.56% 2.83 kB 3.80 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +35.83% 7.13 kB 9.68 kB +34.56% 2.83 kB 3.80 kB
facebook-www/ReactFlightDOMRelayClient-prod.classic.js +35.71% 13.54 kB 18.38 kB +36.55% 3.37 kB 4.60 kB
facebook-www/ReactFlightDOMRelayClient-prod.modern.js +35.71% 13.54 kB 18.38 kB +36.55% 3.37 kB 4.60 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.min.js +34.07% 7.50 kB 10.06 kB +32.53% 3.01 kB 3.98 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.min.js +34.07% 7.50 kB 10.06 kB +32.53% 3.01 kB 3.98 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.min.js +34.07% 7.50 kB 10.06 kB +32.53% 3.01 kB 3.98 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js +33.65% 7.58 kB 10.14 kB +31.40% 3.07 kB 4.03 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js +33.65% 7.58 kB 10.14 kB +31.40% 3.07 kB 4.03 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js +33.65% 7.58 kB 10.14 kB +31.40% 3.07 kB 4.03 kB
oss-experimental/react-client/cjs/react-client-flight.production.min.js +33.57% 6.32 kB 8.44 kB +32.71% 2.53 kB 3.35 kB
oss-stable-semver/react-client/cjs/react-client-flight.production.min.js +33.57% 6.32 kB 8.44 kB +32.71% 2.53 kB 3.35 kB
oss-stable/react-client/cjs/react-client-flight.production.min.js +33.57% 6.32 kB 8.44 kB +32.71% 2.53 kB 3.35 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.min.js +8.15% 9.81 kB 10.61 kB +7.37% 3.87 kB 4.15 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.min.js +8.15% 9.81 kB 10.61 kB +7.37% 3.87 kB 4.15 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.min.js +8.15% 9.81 kB 10.61 kB +7.37% 3.87 kB 4.15 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.production.min.js +7.90% 10.07 kB 10.87 kB +7.14% 3.98 kB 4.26 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.production.min.js +7.90% 10.07 kB 10.87 kB +7.14% 3.98 kB 4.26 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.production.min.js +7.90% 10.07 kB 10.87 kB +7.14% 3.98 kB 4.26 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +5.27% 48.86 kB 51.43 kB +6.23% 11.95 kB 12.69 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +5.27% 48.86 kB 51.43 kB +6.23% 11.95 kB 12.69 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +5.27% 48.86 kB 51.43 kB +6.23% 11.95 kB 12.69 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +5.22% 51.95 kB 54.66 kB +6.30% 12.14 kB 12.90 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +5.22% 51.95 kB 54.66 kB +6.30% 12.14 kB 12.90 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +5.22% 51.95 kB 54.66 kB +6.30% 12.14 kB 12.90 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +3.26% 21.11 kB 21.80 kB +2.64% 7.51 kB 7.71 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +3.26% 21.11 kB 21.80 kB +2.64% 7.51 kB 7.71 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +3.26% 21.11 kB 21.80 kB +2.64% 7.51 kB 7.71 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +3.21% 21.42 kB 22.11 kB +2.59% 7.61 kB 7.81 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +3.21% 21.42 kB 22.11 kB +2.59% 7.61 kB 7.81 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +3.21% 21.42 kB 22.11 kB +2.59% 7.61 kB 7.81 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +3.19% 21.32 kB 22.00 kB +2.66% 7.60 kB 7.81 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +3.19% 21.32 kB 22.00 kB +2.66% 7.60 kB 7.81 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +3.19% 21.32 kB 22.00 kB +2.66% 7.60 kB 7.81 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +2.99% 22.34 kB 23.00 kB +2.50% 7.92 kB 8.12 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +2.99% 22.34 kB 23.00 kB +2.50% 7.92 kB 8.12 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +2.99% 22.34 kB 23.00 kB +2.50% 7.92 kB 8.12 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +2.91% 22.90 kB 23.57 kB +2.33% 8.11 kB 8.30 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +2.91% 22.90 kB 23.57 kB +2.33% 8.11 kB 8.30 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +2.91% 22.90 kB 23.57 kB +2.33% 8.11 kB 8.30 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +2.81% 88.20 kB 90.68 kB +2.23% 21.46 kB 21.94 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +2.81% 88.20 kB 90.68 kB +2.23% 21.46 kB 21.94 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +2.81% 88.20 kB 90.68 kB +2.23% 21.46 kB 21.94 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +2.80% 88.61 kB 91.09 kB +2.22% 21.58 kB 22.06 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +2.80% 88.61 kB 91.09 kB +2.22% 21.58 kB 22.06 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +2.80% 88.61 kB 91.09 kB +2.22% 21.58 kB 22.06 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +2.79% 93.28 kB 95.88 kB +2.21% 21.81 kB 22.29 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +2.79% 93.28 kB 95.88 kB +2.21% 21.81 kB 22.29 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +2.79% 93.28 kB 95.88 kB +2.21% 21.81 kB 22.29 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2.71% 91.52 kB 94.00 kB +2.20% 21.93 kB 22.42 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2.71% 91.52 kB 94.00 kB +2.20% 21.93 kB 22.42 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2.71% 91.52 kB 94.00 kB +2.20% 21.93 kB 22.42 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +2.64% 93.83 kB 96.31 kB +2.12% 22.61 kB 23.09 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +2.64% 93.83 kB 96.31 kB +2.12% 22.61 kB 23.09 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +2.64% 93.83 kB 96.31 kB +2.12% 22.61 kB 23.09 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-relay/flight/ReactFlightNativeRelayClient-dev.js +106.88% 20.82 kB 43.08 kB +95.82% 5.43 kB 10.64 kB
facebook-www/ReactFlightDOMRelayClient-dev.classic.js +98.12% 22.50 kB 44.58 kB +89.99% 5.65 kB 10.74 kB
facebook-www/ReactFlightDOMRelayClient-dev.modern.js +98.12% 22.50 kB 44.58 kB +89.99% 5.65 kB 10.74 kB
oss-experimental/react-client/cjs/react-client-flight.development.js +93.21% 23.15 kB 44.73 kB +84.36% 6.11 kB 11.27 kB
oss-stable-semver/react-client/cjs/react-client-flight.development.js +93.21% 23.15 kB 44.73 kB +84.36% 6.11 kB 11.27 kB
oss-stable/react-client/cjs/react-client-flight.development.js +93.21% 23.15 kB 44.73 kB +84.36% 6.11 kB 11.27 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +81.10% 26.61 kB 48.19 kB +75.69% 6.80 kB 11.94 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +81.10% 26.61 kB 48.19 kB +75.69% 6.80 kB 11.94 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +81.10% 26.61 kB 48.19 kB +75.69% 6.80 kB 11.94 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +76.68% 28.14 kB 49.72 kB +71.23% 7.24 kB 12.39 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +76.68% 28.14 kB 49.72 kB +71.23% 7.24 kB 12.39 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +76.68% 28.14 kB 49.72 kB +71.23% 7.24 kB 12.39 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +76.09% 28.36 kB 49.94 kB +70.34% 7.32 kB 12.47 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +76.09% 28.36 kB 49.94 kB +70.34% 7.32 kB 12.47 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +76.09% 28.36 kB 49.94 kB +70.34% 7.32 kB 12.47 kB
facebook-relay/flight/ReactFlightNativeRelayClient-prod.js +38.80% 12.46 kB 17.30 kB +38.07% 3.23 kB 4.45 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +35.83% 7.13 kB 9.68 kB +34.56% 2.83 kB 3.80 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +35.83% 7.13 kB 9.68 kB +34.56% 2.83 kB 3.80 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +35.83% 7.13 kB 9.68 kB +34.56% 2.83 kB 3.80 kB
facebook-www/ReactFlightDOMRelayClient-prod.classic.js +35.71% 13.54 kB 18.38 kB +36.55% 3.37 kB 4.60 kB
facebook-www/ReactFlightDOMRelayClient-prod.modern.js +35.71% 13.54 kB 18.38 kB +36.55% 3.37 kB 4.60 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.min.js +34.07% 7.50 kB 10.06 kB +32.53% 3.01 kB 3.98 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.min.js +34.07% 7.50 kB 10.06 kB +32.53% 3.01 kB 3.98 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.min.js +34.07% 7.50 kB 10.06 kB +32.53% 3.01 kB 3.98 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js +33.65% 7.58 kB 10.14 kB +31.40% 3.07 kB 4.03 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js +33.65% 7.58 kB 10.14 kB +31.40% 3.07 kB 4.03 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js +33.65% 7.58 kB 10.14 kB +31.40% 3.07 kB 4.03 kB
oss-experimental/react-client/cjs/react-client-flight.production.min.js +33.57% 6.32 kB 8.44 kB +32.71% 2.53 kB 3.35 kB
oss-stable-semver/react-client/cjs/react-client-flight.production.min.js +33.57% 6.32 kB 8.44 kB +32.71% 2.53 kB 3.35 kB
oss-stable/react-client/cjs/react-client-flight.production.min.js +33.57% 6.32 kB 8.44 kB +32.71% 2.53 kB 3.35 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.min.js +8.15% 9.81 kB 10.61 kB +7.37% 3.87 kB 4.15 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.min.js +8.15% 9.81 kB 10.61 kB +7.37% 3.87 kB 4.15 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.min.js +8.15% 9.81 kB 10.61 kB +7.37% 3.87 kB 4.15 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.production.min.js +7.90% 10.07 kB 10.87 kB +7.14% 3.98 kB 4.26 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.production.min.js +7.90% 10.07 kB 10.87 kB +7.14% 3.98 kB 4.26 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.production.min.js +7.90% 10.07 kB 10.87 kB +7.14% 3.98 kB 4.26 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +5.27% 48.86 kB 51.43 kB +6.23% 11.95 kB 12.69 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +5.27% 48.86 kB 51.43 kB +6.23% 11.95 kB 12.69 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +5.27% 48.86 kB 51.43 kB +6.23% 11.95 kB 12.69 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +5.22% 51.95 kB 54.66 kB +6.30% 12.14 kB 12.90 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +5.22% 51.95 kB 54.66 kB +6.30% 12.14 kB 12.90 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +5.22% 51.95 kB 54.66 kB +6.30% 12.14 kB 12.90 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +3.26% 21.11 kB 21.80 kB +2.64% 7.51 kB 7.71 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +3.26% 21.11 kB 21.80 kB +2.64% 7.51 kB 7.71 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +3.26% 21.11 kB 21.80 kB +2.64% 7.51 kB 7.71 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +3.21% 21.42 kB 22.11 kB +2.59% 7.61 kB 7.81 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +3.21% 21.42 kB 22.11 kB +2.59% 7.61 kB 7.81 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +3.21% 21.42 kB 22.11 kB +2.59% 7.61 kB 7.81 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +3.19% 21.32 kB 22.00 kB +2.66% 7.60 kB 7.81 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +3.19% 21.32 kB 22.00 kB +2.66% 7.60 kB 7.81 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +3.19% 21.32 kB 22.00 kB +2.66% 7.60 kB 7.81 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +2.99% 22.34 kB 23.00 kB +2.50% 7.92 kB 8.12 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +2.99% 22.34 kB 23.00 kB +2.50% 7.92 kB 8.12 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +2.99% 22.34 kB 23.00 kB +2.50% 7.92 kB 8.12 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +2.91% 22.90 kB 23.57 kB +2.33% 8.11 kB 8.30 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +2.91% 22.90 kB 23.57 kB +2.33% 8.11 kB 8.30 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +2.91% 22.90 kB 23.57 kB +2.33% 8.11 kB 8.30 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +2.81% 88.20 kB 90.68 kB +2.23% 21.46 kB 21.94 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +2.81% 88.20 kB 90.68 kB +2.23% 21.46 kB 21.94 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +2.81% 88.20 kB 90.68 kB +2.23% 21.46 kB 21.94 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +2.80% 88.61 kB 91.09 kB +2.22% 21.58 kB 22.06 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +2.80% 88.61 kB 91.09 kB +2.22% 21.58 kB 22.06 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +2.80% 88.61 kB 91.09 kB +2.22% 21.58 kB 22.06 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +2.79% 93.28 kB 95.88 kB +2.21% 21.81 kB 22.29 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +2.79% 93.28 kB 95.88 kB +2.21% 21.81 kB 22.29 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +2.79% 93.28 kB 95.88 kB +2.21% 21.81 kB 22.29 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2.71% 91.52 kB 94.00 kB +2.20% 21.93 kB 22.42 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2.71% 91.52 kB 94.00 kB +2.20% 21.93 kB 22.42 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2.71% 91.52 kB 94.00 kB +2.20% 21.93 kB 22.42 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +2.64% 93.83 kB 96.31 kB +2.12% 22.61 kB 23.09 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +2.64% 93.83 kB 96.31 kB +2.12% 22.61 kB 23.09 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +2.64% 93.83 kB 96.31 kB +2.12% 22.61 kB 23.09 kB

Generated by 🚫 dangerJS against 249f02a

Copy link
Collaborator

@acdlite acdlite left a comment

Choose a reason for hiding this comment

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

🎉

@sebmarkbage sebmarkbage merged commit aef7ce5 into facebook:main May 3, 2023
github-actions bot pushed a commit that referenced this pull request May 3, 2023
This automatically exposes `$$FORM_ACTIONS` on Server References coming
from Flight. So that when they're used in a form action, we can encode
the ID for the server reference as a hidden field or as part of the name
of a button.

If the Server Action is a bound function it can have complex data
associated with it. In this case this additional data is encoded as
additional form fields.

To process a POST on the server there's now a `decodeAction` helper that
can take one of these progressive posts from FormData and give you a
function that is prebound with the correct closure and FormData so that
you can just invoke it.

I updated the fixture which now has a "Server State" that gets
automatically refreshed. This also lets us visualize form fields.
There's no "Action State" here for showing error messages that are not
thrown, that's still up to user space.

DiffTrain build for [aef7ce5](aef7ce5)
acdlite added a commit to acdlite/next.js that referenced this pull request May 3, 2023
Includes the following upstream changes:

- [aef7ce554](https://github.com/facebook/react/commits/aef7ce554) [Flight] Progressively Enhanced Server Actions ([vercel#26774](facebook/react#26774)) (Sebastian Markbåge)
- [c10010a6a](https://github.com/facebook/react/commits/c10010a6a) [Fizz] Gracefully handle suspending in DOM configs ([vercel#26768](facebook/react#26768)) (Sebastian Markbåge)
- [f533cee8c](https://github.com/facebook/react/commits/f533cee8c) Add useFormStatus to Flight fixture ([#26773](facebook/react#26773)) (Andrew Clark)
- [2c1117a8d](https://github.com/facebook/react/commits/2c1117a8d) Reuse request so that a ReabableStream body does not become disturbed ([vercel#26771](facebook/react#26771)) (Andrew Gadzik)
- [fa7a447b9](https://github.com/facebook/react/commits/fa7a447b9) [Fizz] Check for nullish values on ReactCustomFormAction ([vercel#26770](facebook/react#26770)) (Sebastian Markbåge)
acdlite added a commit to vercel/next.js that referenced this pull request May 4, 2023
Includes the following upstream changes:

- [aef7ce554](https://github.com/facebook/react/commits/aef7ce554)
[Flight] Progressively Enhanced Server Actions
([#26774](facebook/react#26774)) (Sebastian
Markbåge)
- [c10010a6a](https://github.com/facebook/react/commits/c10010a6a)
[Fizz] Gracefully handle suspending in DOM configs
([#26768](facebook/react#26768)) (Sebastian
Markbåge)
- [f533cee8c](https://github.com/facebook/react/commits/f533cee8c) Add
useFormStatus to Flight fixture
([#26773](facebook/react#26773)) (Andrew Clark)
- [2c1117a8d](https://github.com/facebook/react/commits/2c1117a8d) Reuse
request so that a ReabableStream body does not become disturbed
([#26771](facebook/react#26771)) (Andrew Gadzik)
- [fa7a447b9](https://github.com/facebook/react/commits/fa7a447b9)
[Fizz] Check for nullish values on ReactCustomFormAction
([#26770](facebook/react#26770)) (Sebastian
Markbåge)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
sebmarkbage pushed a commit to sebmarkbage/next.js that referenced this pull request May 4, 2023
Includes the following upstream changes:

- [aef7ce554](https://github.com/facebook/react/commits/aef7ce554) [Flight] Progressively Enhanced Server Actions ([vercel#26774](facebook/react#26774)) (Sebastian Markbåge)
- [c10010a6a](https://github.com/facebook/react/commits/c10010a6a) [Fizz] Gracefully handle suspending in DOM configs ([vercel#26768](facebook/react#26768)) (Sebastian Markbåge)
- [f533cee8c](https://github.com/facebook/react/commits/f533cee8c) Add useFormStatus to Flight fixture ([#26773](facebook/react#26773)) (Andrew Clark)
- [2c1117a8d](https://github.com/facebook/react/commits/2c1117a8d) Reuse request so that a ReabableStream body does not become disturbed ([vercel#26771](facebook/react#26771)) (Andrew Gadzik)
- [fa7a447b9](https://github.com/facebook/react/commits/fa7a447b9) [Fizz] Check for nullish values on ReactCustomFormAction ([vercel#26770](facebook/react#26770)) (Sebastian Markbåge)
formAction={async () => {
const result = await action();
console.log(result);
}}>
Copy link
Collaborator

@unstubbable unstubbable May 4, 2023

Choose a reason for hiding this comment

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

@sebmarkbage It seems that progressively enhanced forms are only supported for voidy server actions. Or is that only a limitation of the Flight Fixture because closures with 'use server' directives are not supported here, and if they were, we could define the action/formAction as before, and read the result?

EDIT: Hm, actually no, even if they were supported here, we still couldn't do anything with the result on the client, because the closure would run on the server. 🤦 Also, I now realise that progressively enhanced forms only make sense if the action is voidy, i.e. the mutation must result in some server-side state that can be rendered.

ztanner added a commit to vercel/next.js that referenced this pull request Nov 29, 2023
### What?
When handling a server action, in the non-progressive enhanced case,
React will attempt to parse the request body before verifying if a valid
server action is received. This results in an "Error: Connection Closed"
error being thrown, rather than ignoring the action and failing more
gracefully

### Why?
To support progressive enhancement with form actions, the `actionId`
value is added as a hidden input in the form, so the action ID from the
header shouldn't be verified until determining that we've reached the
non-PE case. ([React
ref](facebook/react#26774)). However, in
#49187, support was added for a
URL encoded form (which is not currently used, as indicated on the PR).

Despite it not being used for server actions, it's currently possible to
trigger this codepath, ie by calling redirect in an action handler with
a 307/308 status code with some data in the URL. This would result in a
500 error.

### How?
React should not attempt to parse the URL encoded form data until after
we've verified the server action header for the non-PE case.

x-ref NEXT-1733
[Slack
context](https://vercel.slack.com/archives/C03S8ED1DKM/p1700674895218399?thread_ts=1700060786.749079&cid=C03S8ED1DKM)
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
This automatically exposes `$$FORM_ACTIONS` on Server References coming
from Flight. So that when they're used in a form action, we can encode
the ID for the server reference as a hidden field or as part of the name
of a button.

If the Server Action is a bound function it can have complex data
associated with it. In this case this additional data is encoded as
additional form fields.

To process a POST on the server there's now a `decodeAction` helper that
can take one of these progressive posts from FormData and give you a
function that is prebound with the correct closure and FormData so that
you can just invoke it.

I updated the fixture which now has a "Server State" that gets
automatically refreshed. This also lets us visualize form fields.
There's no "Action State" here for showing error messages that are not
thrown, that's still up to user space.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
This automatically exposes `$$FORM_ACTIONS` on Server References coming
from Flight. So that when they're used in a form action, we can encode
the ID for the server reference as a hidden field or as part of the name
of a button.

If the Server Action is a bound function it can have complex data
associated with it. In this case this additional data is encoded as
additional form fields.

To process a POST on the server there's now a `decodeAction` helper that
can take one of these progressive posts from FormData and give you a
function that is prebound with the correct closure and FormData so that
you can just invoke it.

I updated the fixture which now has a "Server State" that gets
automatically refreshed. This also lets us visualize form fields.
There's no "Action State" here for showing error messages that are not
thrown, that's still up to user space.

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

6 participants