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 [d6dcad6a8b](https://github.com/facebook/react/commit/d6dcad6a8beaeec0513a9851d1e0fe1181932360)
This commit is contained in:
acdlite
2023-09-14 15:51:36 +00:00
parent 97bcd7f290
commit 0a7bf73f2e
8 changed files with 18 additions and 21 deletions
+1 -1
View File
@@ -1 +1 @@
caa716d50bdeef3a1ac5e3e0cfcc14f4d91f2028
d6dcad6a8beaeec0513a9851d1e0fe1181932360
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");
var ReactVersion = "18.3.0-www-classic-360a070f";
var ReactVersion = "18.3.0-www-classic-a7988d89";
// This refers to a WWW module.
var warningWWW = require("warning");
@@ -10392,11 +10392,10 @@ function finishFunctionComponent(
) {
var didEmitFormStateMarkers = false;
if (formStateCount !== 0) {
if (formStateCount !== 0 && request.formState !== null) {
// For each useFormState hook, emit a marker that indicates whether we
// rendered using the form state passed at the root.
// TODO: As an optimization, Fizz should only emit these markers if form
// state is passed at the root.
// rendered using the form state passed at the root. We only emit these
// markers if form state is passed at the root.
var segment = task.blockedSegment;
if (segment === null);
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");
var ReactVersion = "18.3.0-www-modern-b814d906";
var ReactVersion = "18.3.0-www-modern-de2d6098";
// This refers to a WWW module.
var warningWWW = require("warning");
@@ -10140,11 +10140,10 @@ function finishFunctionComponent(
) {
var didEmitFormStateMarkers = false;
if (formStateCount !== 0) {
if (formStateCount !== 0 && request.formState !== null) {
// For each useFormState hook, emit a marker that indicates whether we
// rendered using the form state passed at the root.
// TODO: As an optimization, Fizz should only emit these markers if form
// state is passed at the root.
// rendered using the form state passed at the root. We only emit these
// markers if form state is passed at the root.
var segment = task.blockedSegment;
if (segment === null);
@@ -3063,7 +3063,7 @@ function finishFunctionComponent(
formStateMatchingIndex
) {
var didEmitFormStateMarkers = !1;
if (0 !== formStateCount) {
if (0 !== formStateCount && null !== request.formState) {
var segment = task.blockedSegment;
if (null !== segment) {
didEmitFormStateMarkers = !0;
@@ -4556,4 +4556,4 @@ exports.renderToString = function (children, options) {
'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'
);
};
exports.version = "18.3.0-www-classic-f04a97ef";
exports.version = "18.3.0-www-classic-5dc27933";
@@ -3055,7 +3055,7 @@ function finishFunctionComponent(
formStateMatchingIndex
) {
var didEmitFormStateMarkers = !1;
if (0 !== formStateCount) {
if (0 !== formStateCount && null !== request.formState) {
var segment = task.blockedSegment;
if (null !== segment) {
didEmitFormStateMarkers = !0;
@@ -4523,4 +4523,4 @@ exports.renderToString = function (children, options) {
'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'
);
};
exports.version = "18.3.0-www-modern-b31a402c";
exports.version = "18.3.0-www-modern-a538c776";
@@ -10043,11 +10043,10 @@ function finishFunctionComponent(
) {
var didEmitFormStateMarkers = false;
if (formStateCount !== 0) {
if (formStateCount !== 0 && request.formState !== null) {
// For each useFormState hook, emit a marker that indicates whether we
// rendered using the form state passed at the root.
// TODO: As an optimization, Fizz should only emit these markers if form
// state is passed at the root.
// rendered using the form state passed at the root. We only emit these
// markers if form state is passed at the root.
var segment = task.blockedSegment;
if (segment === null);
@@ -2849,7 +2849,7 @@ function finishFunctionComponent(
formStateMatchingIndex
) {
var didEmitFormStateMarkers = !1;
if (0 !== formStateCount) {
if (0 !== formStateCount && null !== request.formState) {
var segment = task.blockedSegment;
if (null !== segment) {
didEmitFormStateMarkers = !0;
@@ -24360,7 +24360,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-www-modern-f5e6bf9d";
var ReactVersion = "18.3.0-www-modern-fa8b400b";
// Might add PROFILE later.