Skip to content

Commit

Permalink
[Flight] Unify plain Server Component and forwardRef under one functi…
Browse files Browse the repository at this point in the history
…on (#28261)

This used to be trivial but it's no longer trivial.

In Fizz and Fiber this is split into renderWithHooks and
finishFunctionComponent since they also support indeterminate
components.

Interestingly thanks to this unification we always call functions with
an arity of 2 which is a bit weird - with the second argument being
undefined in everything except forwardRef and legacy context consumers.

This makes Flight makes the same thing but we could also call it with an
arity of 1.

Since Flight errors early if you try to pass it a ref, and there's no
legacy context, the second arg is always undefined.

The practical change in this PR is that returning a Promise from a
forwardRef now turns it into a lazy. We previously didn't support async
forwardRef since it wasn't supported on the client. However, since
eventually this will be supported by child-as-a-promise it seems fine to
support it.

DiffTrain build for commit f07ac1e.
  • Loading branch information
sebmarkbage committed Feb 7, 2024
1 parent 571a247 commit 1cff685
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25725,7 +25725,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-canary-1beb94133-20240206";
var ReactVersion = "18.3.0-canary-f07ac1e26-20240206";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9157,7 +9157,7 @@ var devToolsConfig$jscomp$inline_1012 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-1beb94133-20240206",
version: "18.3.0-canary-f07ac1e26-20240206",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1190 = {
Expand Down Expand Up @@ -9188,7 +9188,7 @@ var internals$jscomp$inline_1190 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-1beb94133-20240206"
reconcilerVersion: "18.3.0-canary-f07ac1e26-20240206"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1191 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9585,7 +9585,7 @@ var devToolsConfig$jscomp$inline_1054 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-1beb94133-20240206",
version: "18.3.0-canary-f07ac1e26-20240206",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1231 = {
Expand Down Expand Up @@ -9616,7 +9616,7 @@ var internals$jscomp$inline_1231 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-1beb94133-20240206"
reconcilerVersion: "18.3.0-canary-f07ac1e26-20240206"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1232 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (__DEV__) {
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = "18.3.0-canary-1beb94133-20240206";
var ReactVersion = "18.3.0-canary-f07ac1e26-20240206";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,4 +550,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-1beb94133-20240206";
exports.version = "18.3.0-canary-f07ac1e26-20240206";
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-1beb94133-20240206";
exports.version = "18.3.0-canary-f07ac1e26-20240206";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1beb94133a93a433669a893aef02dd5afec07394
f07ac1e2680a26c5b3bf9c651d62c792de71d46d

0 comments on commit 1cff685

Please sign in to comment.