Skip to content

Commit 0a7bf73

Browse files
committed
useFormState: Only emit markers if postback state is provided (#27374)
This is an optimization where useFormState will only emit extra comment markers if a form state is passed at the root. If no state is passed, we don't need to emit anything because none of the hooks will match. DiffTrain build for [d6dcad6](d6dcad6)
1 parent 97bcd7f commit 0a7bf73

8 files changed

+18
-21
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
caa716d50bdeef3a1ac5e3e0cfcc14f4d91f2028
1+
d6dcad6a8beaeec0513a9851d1e0fe1181932360

compiled/facebook-www/ReactDOMServer-dev.classic.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-classic-360a070f";
22+
var ReactVersion = "18.3.0-www-classic-a7988d89";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -10392,11 +10392,10 @@ function finishFunctionComponent(
1039210392
) {
1039310393
var didEmitFormStateMarkers = false;
1039410394

10395-
if (formStateCount !== 0) {
10395+
if (formStateCount !== 0 && request.formState !== null) {
1039610396
// For each useFormState hook, emit a marker that indicates whether we
10397-
// rendered using the form state passed at the root.
10398-
// TODO: As an optimization, Fizz should only emit these markers if form
10399-
// state is passed at the root.
10397+
// rendered using the form state passed at the root. We only emit these
10398+
// markers if form state is passed at the root.
1040010399
var segment = task.blockedSegment;
1040110400

1040210401
if (segment === null);

compiled/facebook-www/ReactDOMServer-dev.modern.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-modern-b814d906";
22+
var ReactVersion = "18.3.0-www-modern-de2d6098";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -10140,11 +10140,10 @@ function finishFunctionComponent(
1014010140
) {
1014110141
var didEmitFormStateMarkers = false;
1014210142

10143-
if (formStateCount !== 0) {
10143+
if (formStateCount !== 0 && request.formState !== null) {
1014410144
// For each useFormState hook, emit a marker that indicates whether we
10145-
// rendered using the form state passed at the root.
10146-
// TODO: As an optimization, Fizz should only emit these markers if form
10147-
// state is passed at the root.
10145+
// rendered using the form state passed at the root. We only emit these
10146+
// markers if form state is passed at the root.
1014810147
var segment = task.blockedSegment;
1014910148

1015010149
if (segment === null);

compiled/facebook-www/ReactDOMServer-prod.classic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,7 +3063,7 @@ function finishFunctionComponent(
30633063
formStateMatchingIndex
30643064
) {
30653065
var didEmitFormStateMarkers = !1;
3066-
if (0 !== formStateCount) {
3066+
if (0 !== formStateCount && null !== request.formState) {
30673067
var segment = task.blockedSegment;
30683068
if (null !== segment) {
30693069
didEmitFormStateMarkers = !0;
@@ -4556,4 +4556,4 @@ exports.renderToString = function (children, options) {
45564556
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
45574557
);
45584558
};
4559-
exports.version = "18.3.0-www-classic-f04a97ef";
4559+
exports.version = "18.3.0-www-classic-5dc27933";

compiled/facebook-www/ReactDOMServer-prod.modern.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ function finishFunctionComponent(
30553055
formStateMatchingIndex
30563056
) {
30573057
var didEmitFormStateMarkers = !1;
3058-
if (0 !== formStateCount) {
3058+
if (0 !== formStateCount && null !== request.formState) {
30593059
var segment = task.blockedSegment;
30603060
if (null !== segment) {
30613061
didEmitFormStateMarkers = !0;
@@ -4523,4 +4523,4 @@ exports.renderToString = function (children, options) {
45234523
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
45244524
);
45254525
};
4526-
exports.version = "18.3.0-www-modern-b31a402c";
4526+
exports.version = "18.3.0-www-modern-a538c776";

compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10043,11 +10043,10 @@ function finishFunctionComponent(
1004310043
) {
1004410044
var didEmitFormStateMarkers = false;
1004510045

10046-
if (formStateCount !== 0) {
10046+
if (formStateCount !== 0 && request.formState !== null) {
1004710047
// For each useFormState hook, emit a marker that indicates whether we
10048-
// rendered using the form state passed at the root.
10049-
// TODO: As an optimization, Fizz should only emit these markers if form
10050-
// state is passed at the root.
10048+
// rendered using the form state passed at the root. We only emit these
10049+
// markers if form state is passed at the root.
1005110050
var segment = task.blockedSegment;
1005210051

1005310052
if (segment === null);

compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2849,7 +2849,7 @@ function finishFunctionComponent(
28492849
formStateMatchingIndex
28502850
) {
28512851
var didEmitFormStateMarkers = !1;
2852-
if (0 !== formStateCount) {
2852+
if (0 !== formStateCount && null !== request.formState) {
28532853
var segment = task.blockedSegment;
28542854
if (null !== segment) {
28552855
didEmitFormStateMarkers = !0;

compiled/facebook-www/ReactTestRenderer-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24360,7 +24360,7 @@ function createFiberRoot(
2436024360
return root;
2436124361
}
2436224362

24363-
var ReactVersion = "18.3.0-www-modern-f5e6bf9d";
24363+
var ReactVersion = "18.3.0-www-modern-fa8b400b";
2436424364

2436524365
// Might add PROFILE later.
2436624366

0 commit comments

Comments
 (0)