Skip to content

Commit 8ef2e21

Browse files
committed
[compiler] Add hint to name variables with "Ref" suffix (#34125)
If you have a ref that the compiler doesn't know is a ref (say, a value returned from a custom hook) and try to assign its `.current = ...`, we currently fail with a generic error that hook return values are not mutable. However, an assignment to `.current` specifically is a very strong hint that the value is likely to be a ref. So in this PR, we track the reason for the mutation and if it ends up being an error, we use it to show an additional hint to the user. See the fixture for an example of the message. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34125). * #34126 * __->__ #34125 * #34124 DiffTrain build for [724b324](724b324)
1 parent 52f44c7 commit 8ef2e21

26 files changed

+181
-131
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.2.0-native-fb-45a6532a-20250815
1+
19.2.0-native-fb-724b324b-20250815

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<d0f5979067609b87103f4669dea3219a>>
10+
* @generated SignedSource<<266ca632c8ad19919076eb99ea777680>>
1111
*/
1212

1313
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
404404
exports.useFormStatus = function () {
405405
return resolveDispatcher().useHostTransitionStatus();
406406
};
407-
exports.version = "19.2.0-native-fb-45a6532a-20250815";
407+
exports.version = "19.2.0-native-fb-724b324b-20250815";
408408
})();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<044785886ece60487152664c85e45d4e>>
10+
* @generated SignedSource<<7d16ca6cedac12328544fc384b86c85d>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-45a6532a-20250815";
206+
exports.version = "19.2.0-native-fb-724b324b-20250815";

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<044785886ece60487152664c85e45d4e>>
10+
* @generated SignedSource<<7d16ca6cedac12328544fc384b86c85d>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-45a6532a-20250815";
206+
exports.version = "19.2.0-native-fb-724b324b-20250815";

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<290794d6271048796c259fef1f9b16f9>>
10+
* @generated SignedSource<<cb8069b8e430eed369dcd379dc088625>>
1111
*/
1212

1313
/*
@@ -29362,11 +29362,11 @@ __DEV__ &&
2936229362
};
2936329363
(function () {
2936429364
var isomorphicReactPackageVersion = React.version;
29365-
if ("19.2.0-native-fb-45a6532a-20250815" !== isomorphicReactPackageVersion)
29365+
if ("19.2.0-native-fb-724b324b-20250815" !== isomorphicReactPackageVersion)
2936629366
throw Error(
2936729367
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2936829368
(isomorphicReactPackageVersion +
29369-
"\n - react-dom: 19.2.0-native-fb-45a6532a-20250815\nLearn more: https://react.dev/warnings/version-mismatch")
29369+
"\n - react-dom: 19.2.0-native-fb-724b324b-20250815\nLearn more: https://react.dev/warnings/version-mismatch")
2937029370
);
2937129371
})();
2937229372
("function" === typeof Map &&
@@ -29403,10 +29403,10 @@ __DEV__ &&
2940329403
!(function () {
2940429404
var internals = {
2940529405
bundleType: 1,
29406-
version: "19.2.0-native-fb-45a6532a-20250815",
29406+
version: "19.2.0-native-fb-724b324b-20250815",
2940729407
rendererPackageName: "react-dom",
2940829408
currentDispatcherRef: ReactSharedInternals,
29409-
reconcilerVersion: "19.2.0-native-fb-45a6532a-20250815"
29409+
reconcilerVersion: "19.2.0-native-fb-724b324b-20250815"
2941029410
};
2941129411
internals.overrideHookState = overrideHookState;
2941229412
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -29545,5 +29545,5 @@ __DEV__ &&
2954529545
listenToAllSupportedEvents(container);
2954629546
return new ReactDOMHydrationRoot(initialChildren);
2954729547
};
29548-
exports.version = "19.2.0-native-fb-45a6532a-20250815";
29548+
exports.version = "19.2.0-native-fb-724b324b-20250815";
2954929549
})();

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<3bacac12adcfa89586d502a7ee8e7b8a>>
10+
* @generated SignedSource<<6ebdff98663746c53e80db6cc88c2add>>
1111
*/
1212

1313
/*
@@ -17189,14 +17189,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1718917189
};
1719017190
var isomorphicReactPackageVersion$jscomp$inline_2023 = React.version;
1719117191
if (
17192-
"19.2.0-native-fb-45a6532a-20250815" !==
17192+
"19.2.0-native-fb-724b324b-20250815" !==
1719317193
isomorphicReactPackageVersion$jscomp$inline_2023
1719417194
)
1719517195
throw Error(
1719617196
formatProdErrorMessage(
1719717197
527,
1719817198
isomorphicReactPackageVersion$jscomp$inline_2023,
17199-
"19.2.0-native-fb-45a6532a-20250815"
17199+
"19.2.0-native-fb-724b324b-20250815"
1720017200
)
1720117201
);
1720217202
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17218,10 +17218,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1721817218
};
1721917219
var internals$jscomp$inline_2554 = {
1722017220
bundleType: 0,
17221-
version: "19.2.0-native-fb-45a6532a-20250815",
17221+
version: "19.2.0-native-fb-724b324b-20250815",
1722217222
rendererPackageName: "react-dom",
1722317223
currentDispatcherRef: ReactSharedInternals,
17224-
reconcilerVersion: "19.2.0-native-fb-45a6532a-20250815"
17224+
reconcilerVersion: "19.2.0-native-fb-724b324b-20250815"
1722517225
};
1722617226
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1722717227
var hook$jscomp$inline_2555 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17319,4 +17319,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1731917319
listenToAllSupportedEvents(container);
1732017320
return new ReactDOMHydrationRoot(initialChildren);
1732117321
};
17322-
exports.version = "19.2.0-native-fb-45a6532a-20250815";
17322+
exports.version = "19.2.0-native-fb-724b324b-20250815";

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<98f8236ce62ea4e5409e954a18b4bfe0>>
10+
* @generated SignedSource<<321385d79ff059899370511615d55b9c>>
1111
*/
1212

1313
/*
@@ -19199,14 +19199,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1919919199
};
1920019200
var isomorphicReactPackageVersion$jscomp$inline_2274 = React.version;
1920119201
if (
19202-
"19.2.0-native-fb-45a6532a-20250815" !==
19202+
"19.2.0-native-fb-724b324b-20250815" !==
1920319203
isomorphicReactPackageVersion$jscomp$inline_2274
1920419204
)
1920519205
throw Error(
1920619206
formatProdErrorMessage(
1920719207
527,
1920819208
isomorphicReactPackageVersion$jscomp$inline_2274,
19209-
"19.2.0-native-fb-45a6532a-20250815"
19209+
"19.2.0-native-fb-724b324b-20250815"
1921019210
)
1921119211
);
1921219212
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19228,10 +19228,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1922819228
};
1922919229
var internals$jscomp$inline_2281 = {
1923019230
bundleType: 0,
19231-
version: "19.2.0-native-fb-45a6532a-20250815",
19231+
version: "19.2.0-native-fb-724b324b-20250815",
1923219232
rendererPackageName: "react-dom",
1923319233
currentDispatcherRef: ReactSharedInternals,
19234-
reconcilerVersion: "19.2.0-native-fb-45a6532a-20250815",
19234+
reconcilerVersion: "19.2.0-native-fb-724b324b-20250815",
1923519235
getLaneLabelMap: function () {
1923619236
for (
1923719237
var map = new Map(), lane = 1, index$321 = 0;
@@ -19345,4 +19345,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1934519345
listenToAllSupportedEvents(container);
1934619346
return new ReactDOMHydrationRoot(initialChildren);
1934719347
};
19348-
exports.version = "19.2.0-native-fb-45a6532a-20250815";
19348+
exports.version = "19.2.0-native-fb-724b324b-20250815";

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<d913fe1d06b16d8d3af51406ee24d10f>>
10+
* @generated SignedSource<<f79d6915a5018073cf17c920d2aa2a58>>
1111
*/
1212

1313
/*
@@ -29418,11 +29418,11 @@ __DEV__ &&
2941829418
};
2941929419
(function () {
2942029420
var isomorphicReactPackageVersion = React.version;
29421-
if ("19.2.0-native-fb-45a6532a-20250815" !== isomorphicReactPackageVersion)
29421+
if ("19.2.0-native-fb-724b324b-20250815" !== isomorphicReactPackageVersion)
2942229422
throw Error(
2942329423
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2942429424
(isomorphicReactPackageVersion +
29425-
"\n - react-dom: 19.2.0-native-fb-45a6532a-20250815\nLearn more: https://react.dev/warnings/version-mismatch")
29425+
"\n - react-dom: 19.2.0-native-fb-724b324b-20250815\nLearn more: https://react.dev/warnings/version-mismatch")
2942629426
);
2942729427
})();
2942829428
("function" === typeof Map &&
@@ -29459,10 +29459,10 @@ __DEV__ &&
2945929459
!(function () {
2946029460
var internals = {
2946129461
bundleType: 1,
29462-
version: "19.2.0-native-fb-45a6532a-20250815",
29462+
version: "19.2.0-native-fb-724b324b-20250815",
2946329463
rendererPackageName: "react-dom",
2946429464
currentDispatcherRef: ReactSharedInternals,
29465-
reconcilerVersion: "19.2.0-native-fb-45a6532a-20250815"
29465+
reconcilerVersion: "19.2.0-native-fb-724b324b-20250815"
2946629466
};
2946729467
internals.overrideHookState = overrideHookState;
2946829468
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -29917,7 +29917,7 @@ __DEV__ &&
2991729917
exports.useFormStatus = function () {
2991829918
return resolveDispatcher().useHostTransitionStatus();
2991929919
};
29920-
exports.version = "19.2.0-native-fb-45a6532a-20250815";
29920+
exports.version = "19.2.0-native-fb-724b324b-20250815";
2992129921
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2992229922
"function" ===
2992329923
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<8deb54b0da411f0fd77fcee5fe5f9c27>>
10+
* @generated SignedSource<<947ead5518b2be07d5477623e25bebde>>
1111
*/
1212

1313
/*
@@ -17200,14 +17200,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1720017200
};
1720117201
var isomorphicReactPackageVersion$jscomp$inline_2024 = React.version;
1720217202
if (
17203-
"19.2.0-native-fb-45a6532a-20250815" !==
17203+
"19.2.0-native-fb-724b324b-20250815" !==
1720417204
isomorphicReactPackageVersion$jscomp$inline_2024
1720517205
)
1720617206
throw Error(
1720717207
formatProdErrorMessage(
1720817208
527,
1720917209
isomorphicReactPackageVersion$jscomp$inline_2024,
17210-
"19.2.0-native-fb-45a6532a-20250815"
17210+
"19.2.0-native-fb-724b324b-20250815"
1721117211
)
1721217212
);
1721317213
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17229,10 +17229,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1722917229
};
1723017230
var internals$jscomp$inline_2557 = {
1723117231
bundleType: 0,
17232-
version: "19.2.0-native-fb-45a6532a-20250815",
17232+
version: "19.2.0-native-fb-724b324b-20250815",
1723317233
rendererPackageName: "react-dom",
1723417234
currentDispatcherRef: ReactSharedInternals,
17235-
reconcilerVersion: "19.2.0-native-fb-45a6532a-20250815"
17235+
reconcilerVersion: "19.2.0-native-fb-724b324b-20250815"
1723617236
};
1723717237
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1723817238
var hook$jscomp$inline_2558 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17483,4 +17483,4 @@ exports.useFormState = function (action, initialState, permalink) {
1748317483
exports.useFormStatus = function () {
1748417484
return ReactSharedInternals.H.useHostTransitionStatus();
1748517485
};
17486-
exports.version = "19.2.0-native-fb-45a6532a-20250815";
17486+
exports.version = "19.2.0-native-fb-724b324b-20250815";

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<5f7b1a2654134d9857393961ff7698b5>>
10+
* @generated SignedSource<<a85381b5f33bbbf5e9edc7fd7bd0088c>>
1111
*/
1212

1313
/*
@@ -19214,14 +19214,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1921419214
};
1921519215
var isomorphicReactPackageVersion$jscomp$inline_2275 = React.version;
1921619216
if (
19217-
"19.2.0-native-fb-45a6532a-20250815" !==
19217+
"19.2.0-native-fb-724b324b-20250815" !==
1921819218
isomorphicReactPackageVersion$jscomp$inline_2275
1921919219
)
1922019220
throw Error(
1922119221
formatProdErrorMessage(
1922219222
527,
1922319223
isomorphicReactPackageVersion$jscomp$inline_2275,
19224-
"19.2.0-native-fb-45a6532a-20250815"
19224+
"19.2.0-native-fb-724b324b-20250815"
1922519225
)
1922619226
);
1922719227
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19243,10 +19243,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1924319243
};
1924419244
var internals$jscomp$inline_2282 = {
1924519245
bundleType: 0,
19246-
version: "19.2.0-native-fb-45a6532a-20250815",
19246+
version: "19.2.0-native-fb-724b324b-20250815",
1924719247
rendererPackageName: "react-dom",
1924819248
currentDispatcherRef: ReactSharedInternals,
19249-
reconcilerVersion: "19.2.0-native-fb-45a6532a-20250815",
19249+
reconcilerVersion: "19.2.0-native-fb-724b324b-20250815",
1925019250
getLaneLabelMap: function () {
1925119251
for (
1925219252
var map = new Map(), lane = 1, index$321 = 0;
@@ -19513,7 +19513,7 @@ exports.useFormState = function (action, initialState, permalink) {
1951319513
exports.useFormStatus = function () {
1951419514
return ReactSharedInternals.H.useHostTransitionStatus();
1951519515
};
19516-
exports.version = "19.2.0-native-fb-45a6532a-20250815";
19516+
exports.version = "19.2.0-native-fb-724b324b-20250815";
1951719517
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1951819518
"function" ===
1951919519
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)