Skip to content

Commit 1727bec

Browse files
committed
Upgrade tests to use react/jsx-runtime (#28252)
Instead of createElement. We should have done this when we initially released jsx-runtime but better late than never. The general principle is that our tests should be written using the most up-to-date idioms that we recommend for users, except when explicitly testing an edge case or legacy behavior, like for backwards compatibility. Most of the diff is related to tweaking test output and isn't very interesting. I did have to workaround an issue related to component stacks. The component stack logic depends on shared state that lives in the React module. The problem is that most of our tests reset the React module state and re-require a fresh instance of React, React DOM, etc. However, the JSX runtime is not re-required because it's injected by the compiler as a static import. This means its copy of the shared state is no longer the same as the one used by React, causing any warning logged by the JSX runtime to not include a component stack. (This same issue also breaks string refs, but since we're removing those soon I'm not so concerned about that.) The solution I went with for now is to mock the JSX runtime with a proxy that re-requires the module on every function invocation. I don't love this but it will have to do for now. What we should really do is migrate our tests away from manually resetting the module state and use import syntax instead. DiffTrain build for commit 952aa74.
1 parent 3d453eb commit 1727bec

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25600,7 +25600,7 @@ if (__DEV__) {
2560025600
return root;
2560125601
}
2560225602

25603-
var ReactVersion = "18.3.0-canary-2bc7d336a-20240205";
25603+
var ReactVersion = "18.3.0-canary-952aa74f8-20240205";
2560425604

2560525605
// Might add PROFILE later.
2560625606

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9150,7 +9150,7 @@ var devToolsConfig$jscomp$inline_1012 = {
91509150
throw Error("TestRenderer does not support findFiberByHostInstance()");
91519151
},
91529152
bundleType: 0,
9153-
version: "18.3.0-canary-2bc7d336a-20240205",
9153+
version: "18.3.0-canary-952aa74f8-20240205",
91549154
rendererPackageName: "react-test-renderer"
91559155
};
91569156
var internals$jscomp$inline_1190 = {
@@ -9181,7 +9181,7 @@ var internals$jscomp$inline_1190 = {
91819181
scheduleRoot: null,
91829182
setRefreshHandler: null,
91839183
getCurrentFiber: null,
9184-
reconcilerVersion: "18.3.0-canary-2bc7d336a-20240205"
9184+
reconcilerVersion: "18.3.0-canary-952aa74f8-20240205"
91859185
};
91869186
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
91879187
var hook$jscomp$inline_1191 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9578,7 +9578,7 @@ var devToolsConfig$jscomp$inline_1054 = {
95789578
throw Error("TestRenderer does not support findFiberByHostInstance()");
95799579
},
95809580
bundleType: 0,
9581-
version: "18.3.0-canary-2bc7d336a-20240205",
9581+
version: "18.3.0-canary-952aa74f8-20240205",
95829582
rendererPackageName: "react-test-renderer"
95839583
};
95849584
var internals$jscomp$inline_1231 = {
@@ -9609,7 +9609,7 @@ var internals$jscomp$inline_1231 = {
96099609
scheduleRoot: null,
96109610
setRefreshHandler: null,
96119611
getCurrentFiber: null,
9612-
reconcilerVersion: "18.3.0-canary-2bc7d336a-20240205"
9612+
reconcilerVersion: "18.3.0-canary-952aa74f8-20240205"
96139613
};
96149614
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
96159615
var hook$jscomp$inline_1232 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-canary-2bc7d336a-20240205";
27+
var ReactVersion = "18.3.0-canary-952aa74f8-20240205";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,4 +543,4 @@ exports.useSyncExternalStore = function (
543543
exports.useTransition = function () {
544544
return ReactCurrentDispatcher.current.useTransition();
545545
};
546-
exports.version = "18.3.0-canary-2bc7d336a-20240205";
546+
exports.version = "18.3.0-canary-952aa74f8-20240205";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ exports.useSyncExternalStore = function (
539539
exports.useTransition = function () {
540540
return ReactCurrentDispatcher.current.useTransition();
541541
};
542-
exports.version = "18.3.0-canary-2bc7d336a-20240205";
542+
exports.version = "18.3.0-canary-952aa74f8-20240205";
543543
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
544544
"function" ===
545545
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2bc7d336ae7db689699baeb1fffc2c03d8753ffe
1+
952aa74f8e45ed35ac6bf1de10ad5ed5410deac6

0 commit comments

Comments
 (0)