Skip to content

Commit 8d312d7

Browse files
committed
[compiler] Consider setter from useOptimistic non-reactive (#35141)
Closes #35138 DiffTrain build for [0972e23](0972e23)
1 parent b229e26 commit 8d312d7

35 files changed

+127
-88
lines changed

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18963,9 +18963,18 @@ function isRefOrRefLikeMutableType(type) {
1896318963
function isSetStateType(id) {
1896418964
return id.type.kind === 'Function' && id.type.shapeId === 'BuiltInSetState';
1896518965
}
18966+
function isUseActionStateType(id) {
18967+
return (id.type.kind === 'Object' && id.type.shapeId === 'BuiltInUseActionState');
18968+
}
1896618969
function isStartTransitionType(id) {
1896718970
return (id.type.kind === 'Function' && id.type.shapeId === 'BuiltInStartTransition');
1896818971
}
18972+
function isUseOptimisticType(id) {
18973+
return (id.type.kind === 'Object' && id.type.shapeId === 'BuiltInUseOptimistic');
18974+
}
18975+
function isSetOptimisticType(id) {
18976+
return (id.type.kind === 'Function' && id.type.shapeId === 'BuiltInSetOptimistic');
18977+
}
1896918978
function isSetActionStateType(id) {
1897018979
return (id.type.kind === 'Function' && id.type.shapeId === 'BuiltInSetActionState');
1897118980
}
@@ -18987,16 +18996,18 @@ function isStableType(id) {
1898718996
isSetActionStateType(id) ||
1898818997
isDispatcherType(id) ||
1898918998
isUseRefType(id) ||
18990-
isStartTransitionType(id));
18999+
isStartTransitionType(id) ||
19000+
isSetOptimisticType(id));
1899119001
}
1899219002
function isStableTypeContainer(id) {
1899319003
const type_ = id.type;
1899419004
if (type_.kind !== 'Object') {
1899519005
return false;
1899619006
}
1899719007
return (isUseStateType(id) ||
18998-
type_.shapeId === 'BuiltInUseActionState' ||
19008+
isUseActionStateType(id) ||
1899919009
isUseReducerType(id) ||
19010+
isUseOptimisticType(id) ||
1900019011
type_.shapeId === 'BuiltInUseTransition');
1900119012
}
1900219013
function evaluatesToStableTypeOrContainer(env, { value }) {
@@ -19009,6 +19020,7 @@ function evaluatesToStableTypeOrContainer(env, { value }) {
1900919020
case 'useActionState':
1901019021
case 'useRef':
1901119022
case 'useTransition':
19023+
case 'useOptimistic':
1901219024
return true;
1901319025
}
1901419026
}
@@ -22110,6 +22122,8 @@ const BuiltInUseReducerId = 'BuiltInUseReducer';
2211022122
const BuiltInDispatchId = 'BuiltInDispatch';
2211122123
const BuiltInUseContextHookId = 'BuiltInUseContextHook';
2211222124
const BuiltInUseTransitionId = 'BuiltInUseTransition';
22125+
const BuiltInUseOptimisticId = 'BuiltInUseOptimistic';
22126+
const BuiltInSetOptimisticId = 'BuiltInSetOptimistic';
2211322127
const BuiltInStartTransitionId = 'BuiltInStartTransition';
2211422128
const BuiltInFireId = 'BuiltInFire';
2211522129
const BuiltInFireFunctionId = 'BuiltInFireFunction';
@@ -22724,6 +22738,19 @@ addObject(BUILTIN_SHAPES, BuiltInUseTransitionId, [
2272422738
}, BuiltInStartTransitionId),
2272522739
],
2272622740
]);
22741+
addObject(BUILTIN_SHAPES, BuiltInUseOptimisticId, [
22742+
['0', { kind: 'Poly' }],
22743+
[
22744+
'1',
22745+
addFunction(BUILTIN_SHAPES, [], {
22746+
positionalParams: [],
22747+
restParam: Effect.Freeze,
22748+
returnType: PRIMITIVE_TYPE,
22749+
calleeEffect: Effect.Read,
22750+
returnValueKind: ValueKind.Primitive,
22751+
}, BuiltInSetOptimisticId),
22752+
],
22753+
]);
2272722754
addObject(BUILTIN_SHAPES, BuiltInUseActionStateId, [
2272822755
['0', { kind: 'Poly' }],
2272922756
[
@@ -31167,6 +31194,18 @@ const REACT_APIS = [
3116731194
returnValueKind: ValueKind.Frozen,
3116831195
}),
3116931196
],
31197+
[
31198+
'useOptimistic',
31199+
addHook(DEFAULT_SHAPES, {
31200+
positionalParams: [],
31201+
restParam: Effect.Freeze,
31202+
returnType: { kind: 'Object', shapeId: BuiltInUseOptimisticId },
31203+
calleeEffect: Effect.Read,
31204+
hookKind: 'useOptimistic',
31205+
returnValueKind: ValueKind.Frozen,
31206+
returnValueReason: ValueReason.State,
31207+
}),
31208+
],
3117031209
[
3117131210
'use',
3117231211
addFunction(DEFAULT_SHAPES, [], {

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b946a249b560a2d3afe1a1c8553d5491b1767cb3
1+
0972e23908b573faa5beebc0eb1154f792c53b62
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b946a249b560a2d3afe1a1c8553d5491b1767cb3
1+
0972e23908b573faa5beebc0eb1154f792c53b62

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-b946a249-20251117";
1502+
exports.version = "19.3.0-www-classic-0972e239-20251118";
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-b946a249-20251117";
1502+
exports.version = "19.3.0-www-modern-0972e239-20251118";
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-b946a249-20251117";
609+
exports.version = "19.3.0-www-classic-0972e239-20251118";

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-b946a249-20251117";
609+
exports.version = "19.3.0-www-modern-0972e239-20251118";

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-b946a249-20251117";
613+
exports.version = "19.3.0-www-classic-0972e239-20251118";
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-b946a249-20251117";
613+
exports.version = "19.3.0-www-modern-0972e239-20251118";
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
@@ -20466,10 +20466,10 @@ __DEV__ &&
2046620466
(function () {
2046720467
var internals = {
2046820468
bundleType: 1,
20469-
version: "19.3.0-www-classic-b946a249-20251117",
20469+
version: "19.3.0-www-classic-0972e239-20251118",
2047020470
rendererPackageName: "react-art",
2047120471
currentDispatcherRef: ReactSharedInternals,
20472-
reconcilerVersion: "19.3.0-www-classic-b946a249-20251117"
20472+
reconcilerVersion: "19.3.0-www-classic-0972e239-20251118"
2047320473
};
2047420474
internals.overrideHookState = overrideHookState;
2047520475
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -20504,7 +20504,7 @@ __DEV__ &&
2050420504
exports.Shape = Shape;
2050520505
exports.Surface = Surface;
2050620506
exports.Text = Text;
20507-
exports.version = "19.3.0-www-classic-b946a249-20251117";
20507+
exports.version = "19.3.0-www-classic-0972e239-20251118";
2050820508
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2050920509
"function" ===
2051020510
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)