Skip to content

Commit 0cf92e7

Browse files
committed
[compiler] Allow extraneous non-reactive locals (#35190)
The existing exhaustive-deps rule allows omitting non-reactive dependencies, even if they're not memoized. Conceptually, if a value is non-reactive then it cannot semantically change. Even if the value is a new object, that object represents the exact same value and doesn't necessitate redoing downstream computation. Thus its fine to exclude nonreactive dependencies, whether they're a stable type or not. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/35190). * #35201 * #35202 * #35192 * __->__ #35190 DiffTrain build for [67c1487](67c1487)
1 parent 7c9db67 commit 0cf92e7

35 files changed

+88
-92
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53578,8 +53578,7 @@ function validateExhaustiveDependencies(fn) {
5357853578
reason: 'Unexpected function dependency',
5357953579
loc: value.loc,
5358053580
});
53581-
const isRequiredDependency = reactive.has(inferredDependency.identifier.id) ||
53582-
!isStableType(inferredDependency.identifier);
53581+
const isRequiredDependency = reactive.has(inferredDependency.identifier.id);
5358353582
let hasMatchingManualDependency = false;
5358453583
for (const manualDependency of manualDependencies) {
5358553584
if (manualDependency.root.kind === 'NamedLocal' &&
@@ -53605,10 +53604,7 @@ function validateExhaustiveDependencies(fn) {
5360553604
extra.push(dep);
5360653605
}
5360753606
retainWhere(extra, dep => {
53608-
const isNonReactiveStableValue = dep.root.kind === 'NamedLocal' &&
53609-
!dep.root.value.reactive &&
53610-
isStableType(dep.root.value.identifier);
53611-
return !isNonReactiveStableValue;
53607+
return dep.root.kind === 'Global' || dep.root.value.reactive;
5361253608
});
5361353609
if (missing.length !== 0 || extra.length !== 0) {
5361453610
let suggestions = null;

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
454e01e603464b19ec3b6991a7a781cf1908ac84
1+
67c1487ffd872c95a3bb7d8104eac6eca79fe8cb
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
454e01e603464b19ec3b6991a7a781cf1908ac84
1+
67c1487ffd872c95a3bb7d8104eac6eca79fe8cb

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ __DEV__ &&
14991499
exports.useTransition = function () {
15001500
return resolveDispatcher().useTransition();
15011501
};
1502-
exports.version = "19.3.0-www-classic-454e01e6-20251124";
1502+
exports.version = "19.3.0-www-classic-67c1487f-20251124";
15031503
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15041504
"function" ===
15051505
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ __DEV__ &&
14991499
exports.useTransition = function () {
15001500
return resolveDispatcher().useTransition();
15011501
};
1502-
exports.version = "19.3.0-www-modern-454e01e6-20251124";
1502+
exports.version = "19.3.0-www-modern-67c1487f-20251124";
15031503
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15041504
"function" ===
15051505
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,4 +606,4 @@ exports.useSyncExternalStore = function (
606606
exports.useTransition = function () {
607607
return ReactSharedInternals.H.useTransition();
608608
};
609-
exports.version = "19.3.0-www-classic-454e01e6-20251124";
609+
exports.version = "19.3.0-www-classic-67c1487f-20251124";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,4 +606,4 @@ exports.useSyncExternalStore = function (
606606
exports.useTransition = function () {
607607
return ReactSharedInternals.H.useTransition();
608608
};
609-
exports.version = "19.3.0-www-modern-454e01e6-20251124";
609+
exports.version = "19.3.0-www-modern-67c1487f-20251124";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.3.0-www-classic-454e01e6-20251124";
613+
exports.version = "19.3.0-www-classic-67c1487f-20251124";
614614
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
615615
"function" ===
616616
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.3.0-www-modern-454e01e6-20251124";
613+
exports.version = "19.3.0-www-modern-67c1487f-20251124";
614614
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
615615
"function" ===
616616
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20468,10 +20468,10 @@ __DEV__ &&
2046820468
(function () {
2046920469
var internals = {
2047020470
bundleType: 1,
20471-
version: "19.3.0-www-classic-454e01e6-20251124",
20471+
version: "19.3.0-www-classic-67c1487f-20251124",
2047220472
rendererPackageName: "react-art",
2047320473
currentDispatcherRef: ReactSharedInternals,
20474-
reconcilerVersion: "19.3.0-www-classic-454e01e6-20251124"
20474+
reconcilerVersion: "19.3.0-www-classic-67c1487f-20251124"
2047520475
};
2047620476
internals.overrideHookState = overrideHookState;
2047720477
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -20506,7 +20506,7 @@ __DEV__ &&
2050620506
exports.Shape = Shape;
2050720507
exports.Surface = Surface;
2050820508
exports.Text = Text;
20509-
exports.version = "19.3.0-www-classic-454e01e6-20251124";
20509+
exports.version = "19.3.0-www-classic-67c1487f-20251124";
2051020510
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2051120511
"function" ===
2051220512
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)