Skip to content

Commit d45beaf

Browse files
committed
[compiler] Allow assigning ref-accessing functions to objects if not mutated (facebook#34026)
Allows assigning a ref-accessing function to an object so long as that object is not subsequently transitively mutated. We should likely rewrite the ref validation to use the new mutation/aliasing effects, which would provide a more consistent behavior across instruction types and require fewer special cases like this. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34026). * facebook#34027 * __->__ facebook#34026 DiffTrain build for [04a7a61](facebook@04a7a61)
1 parent f1287ad commit d45beaf

26 files changed

+2093
-1706
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-33a2bf78-20250729
1+
19.2.0-native-fb-04a7a619-20250729

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<<f616c8f7f9d908639b4da455f1e82529>>
10+
* @generated SignedSource<<8e8506e8944c458135b0e15d44df4573>>
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-33a2bf78-20250729";
407+
exports.version = "19.2.0-native-fb-04a7a619-20250729";
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<<3ab6e4755163526946ea3c1deea15f89>>
10+
* @generated SignedSource<<8eecf84e4a5270ca13110533ee4b413b>>
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-33a2bf78-20250729";
206+
exports.version = "19.2.0-native-fb-04a7a619-20250729";

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<<3ab6e4755163526946ea3c1deea15f89>>
10+
* @generated SignedSource<<8eecf84e4a5270ca13110533ee4b413b>>
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-33a2bf78-20250729";
206+
exports.version = "19.2.0-native-fb-04a7a619-20250729";

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

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

1313
/*
@@ -6044,6 +6044,19 @@ __DEV__ &&
60446044
throw SuspenseException;
60456045
}
60466046
}
6047+
function resolveLazy(lazyType) {
6048+
try {
6049+
return callLazyInitInDEV(lazyType);
6050+
} catch (x) {
6051+
if (null !== x && "object" === typeof x && "function" === typeof x.then)
6052+
throw (
6053+
((suspendedThenable = x),
6054+
(needsToResetSuspendedThenableDEV = !0),
6055+
SuspenseException)
6056+
);
6057+
throw x;
6058+
}
6059+
}
60476060
function getSuspendedThenable() {
60486061
if (null === suspendedThenable)
60496062
throw Error(
@@ -6259,7 +6272,7 @@ __DEV__ &&
62596272
("object" === typeof elementType &&
62606273
null !== elementType &&
62616274
elementType.$$typeof === REACT_LAZY_TYPE &&
6262-
callLazyInitInDEV(elementType) === current.type))
6275+
resolveLazy(elementType) === current.type))
62636276
)
62646277
return (
62656278
(current = useFiber(current, element.props)),
@@ -6360,7 +6373,7 @@ __DEV__ &&
63606373
);
63616374
case REACT_LAZY_TYPE:
63626375
var _prevDebugInfo = pushDebugInfo(newChild._debugInfo);
6363-
newChild = callLazyInitInDEV(newChild);
6376+
newChild = resolveLazy(newChild);
63646377
returnFiber = createChild(returnFiber, newChild, lanes);
63656378
currentDebugInfo = _prevDebugInfo;
63666379
return returnFiber;
@@ -6436,7 +6449,7 @@ __DEV__ &&
64366449
case REACT_LAZY_TYPE:
64376450
return (
64386451
(key = pushDebugInfo(newChild._debugInfo)),
6439-
(newChild = callLazyInitInDEV(newChild)),
6452+
(newChild = resolveLazy(newChild)),
64406453
(returnFiber = updateSlot(
64416454
returnFiber,
64426455
oldFiber,
@@ -6530,7 +6543,7 @@ __DEV__ &&
65306543
);
65316544
case REACT_LAZY_TYPE:
65326545
var _prevDebugInfo7 = pushDebugInfo(newChild._debugInfo);
6533-
newChild = callLazyInitInDEV(newChild);
6546+
newChild = resolveLazy(newChild);
65346547
returnFiber = updateFromMap(
65356548
existingChildren,
65366549
returnFiber,
@@ -6608,7 +6621,7 @@ __DEV__ &&
66086621
});
66096622
break;
66106623
case REACT_LAZY_TYPE:
6611-
(child = callLazyInitInDEV(child)),
6624+
(child = resolveLazy(child)),
66126625
warnOnInvalidKey(returnFiber, workInProgress, child, knownKeys);
66136626
}
66146627
return knownKeys;
@@ -6887,7 +6900,7 @@ __DEV__ &&
68876900
("object" === typeof key &&
68886901
null !== key &&
68896902
key.$$typeof === REACT_LAZY_TYPE &&
6890-
callLazyInitInDEV(key) === currentFirstChild.type)
6903+
resolveLazy(key) === currentFirstChild.type)
68916904
) {
68926905
deleteRemainingChildren(
68936906
returnFiber,
@@ -6979,7 +6992,7 @@ __DEV__ &&
69796992
case REACT_LAZY_TYPE:
69806993
return (
69816994
(prevDebugInfo = pushDebugInfo(newChild._debugInfo)),
6982-
(newChild = callLazyInitInDEV(newChild)),
6995+
(newChild = resolveLazy(newChild)),
69836996
(returnFiber = reconcileChildFibersImpl(
69846997
returnFiber,
69856998
currentFirstChild,
@@ -11762,8 +11775,8 @@ __DEV__ &&
1176211775
a: {
1176311776
var elementType = workInProgress.elementType;
1176411777
resetSuspendedCurrentOnMountInLegacyMode(current, workInProgress);
11765-
var props = workInProgress.pendingProps;
11766-
var Component = callLazyInitInDEV(elementType);
11778+
var props = workInProgress.pendingProps,
11779+
Component = resolveLazy(elementType);
1176711780
workInProgress.type = Component;
1176811781
if ("function" === typeof Component)
1176911782
if (shouldConstruct(Component)) {
@@ -26783,25 +26796,7 @@ __DEV__ &&
2678326796
pendingUNSAFE_ComponentWillUpdateWarnings = [];
2678426797
pendingLegacyContextWarning = new Map();
2678526798
};
26786-
var SuspenseException = Error(
26787-
"Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`."
26788-
),
26789-
SuspenseyCommitException = Error(
26790-
"Suspense Exception: This is not a real error, and should not leak into userspace. If you're seeing this, it's likely a bug in React."
26791-
),
26792-
SuspenseActionException = Error(
26793-
"Suspense Exception: This is not a real error! It's an implementation detail of `useActionState` to interrupt the current render. You must either rethrow it immediately, or move the `useActionState` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary."
26794-
),
26795-
noopSuspenseyCommitThenable = {
26796-
then: function () {
26797-
console.error(
26798-
'Internal React error: A listener was unexpectedly attached to a "noop" thenable. This is a bug in React. Please file an issue.'
26799-
);
26800-
}
26801-
},
26802-
suspendedThenable = null,
26803-
needsToResetSuspendedThenableDEV = !1,
26804-
callComponent = {
26799+
var callComponent = {
2680526800
react_stack_bottom_frame: function (Component, props, secondArg) {
2680626801
var wasRendering = isRendering;
2680726802
isRendering = !0;
@@ -26918,6 +26913,24 @@ __DEV__ &&
2691826913
},
2691926914
callLazyInitInDEV =
2692026915
callLazyInit.react_stack_bottom_frame.bind(callLazyInit),
26916+
SuspenseException = Error(
26917+
"Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`."
26918+
),
26919+
SuspenseyCommitException = Error(
26920+
"Suspense Exception: This is not a real error, and should not leak into userspace. If you're seeing this, it's likely a bug in React."
26921+
),
26922+
SuspenseActionException = Error(
26923+
"Suspense Exception: This is not a real error! It's an implementation detail of `useActionState` to interrupt the current render. You must either rethrow it immediately, or move the `useActionState` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary."
26924+
),
26925+
noopSuspenseyCommitThenable = {
26926+
then: function () {
26927+
console.error(
26928+
'Internal React error: A listener was unexpectedly attached to a "noop" thenable. This is a bug in React. Please file an issue.'
26929+
);
26930+
}
26931+
},
26932+
suspendedThenable = null,
26933+
needsToResetSuspendedThenableDEV = !1,
2692126934
thenableState$1 = null,
2692226935
thenableIndexCounter$1 = 0,
2692326936
currentDebugInfo = null,
@@ -29012,11 +29025,11 @@ __DEV__ &&
2901229025
};
2901329026
(function () {
2901429027
var isomorphicReactPackageVersion = React.version;
29015-
if ("19.2.0-native-fb-33a2bf78-20250729" !== isomorphicReactPackageVersion)
29028+
if ("19.2.0-native-fb-04a7a619-20250729" !== isomorphicReactPackageVersion)
2901629029
throw Error(
2901729030
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2901829031
(isomorphicReactPackageVersion +
29019-
"\n - react-dom: 19.2.0-native-fb-33a2bf78-20250729\nLearn more: https://react.dev/warnings/version-mismatch")
29032+
"\n - react-dom: 19.2.0-native-fb-04a7a619-20250729\nLearn more: https://react.dev/warnings/version-mismatch")
2902029033
);
2902129034
})();
2902229035
("function" === typeof Map &&
@@ -29053,10 +29066,10 @@ __DEV__ &&
2905329066
!(function () {
2905429067
var internals = {
2905529068
bundleType: 1,
29056-
version: "19.2.0-native-fb-33a2bf78-20250729",
29069+
version: "19.2.0-native-fb-04a7a619-20250729",
2905729070
rendererPackageName: "react-dom",
2905829071
currentDispatcherRef: ReactSharedInternals,
29059-
reconcilerVersion: "19.2.0-native-fb-33a2bf78-20250729"
29072+
reconcilerVersion: "19.2.0-native-fb-04a7a619-20250729"
2906029073
};
2906129074
internals.overrideHookState = overrideHookState;
2906229075
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -29194,5 +29207,5 @@ __DEV__ &&
2919429207
listenToAllSupportedEvents(container);
2919529208
return new ReactDOMHydrationRoot(initialChildren);
2919629209
};
29197-
exports.version = "19.2.0-native-fb-33a2bf78-20250729";
29210+
exports.version = "19.2.0-native-fb-04a7a619-20250729";
2919829211
})();

0 commit comments

Comments
 (0)