[compiler] Option for preserving calls to useMemo/useCallback

Summary: This adds a compiler option to not drop existing manual memoization and leaving useMemo/useCallback in the generated source. Why do we need this, given that we also have options to validate or ensure that existing memoization is preserved? It's because later diffs on this stack are designed to alter the behavior of the memoization that the compiler emits, in order to detect rules of react violations and debug issues. We don't want to change the behavior of user-level memoization, however, since doing so would be altering the semantics of the user's program in an unacceptable way.

ghstack-source-id: 89dccdec9c
Pull Request resolved: https://github.com/facebook/react/pull/29654

DiffTrain build for [28fe581bac](https://github.com/facebook/react/commit/28fe581bac10ca91b0d12d95beb034cfe790f3d0)
This commit is contained in:
mvitousek
2024-05-31 21:07:14 +00:00
parent a8b2593ccb
commit f4e1d9ef03
32 changed files with 58 additions and 58 deletions
+1 -1
View File
@@ -1 +1 @@
8bc81ca90fb0afb3fe4a28d8931733a3e6fef994
28fe581bac10ca91b0d12d95beb034cfe790f3d0
+1 -1
View File
@@ -1 +1 @@
8bc81ca90fb0afb3fe4a28d8931733a3e6fef994
28fe581bac10ca91b0d12d95beb034cfe790f3d0
+1 -1
View File
@@ -22,7 +22,7 @@ if (
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = '19.0.0-www-classic-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-classic-28fe581bac-20240531';
// Re-export dynamic flags from the www version.
var dynamicFeatureFlags = require('ReactFeatureFlags');
+1 -1
View File
@@ -22,7 +22,7 @@ if (
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = '19.0.0-www-modern-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-modern-28fe581bac-20240531';
// Re-export dynamic flags from the www version.
var dynamicFeatureFlags = require('ReactFeatureFlags');
+1 -1
View File
@@ -684,4 +684,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-classic-8bc81ca90f-20240531";
exports.version = "19.0.0-www-classic-28fe581bac-20240531";
+1 -1
View File
@@ -684,4 +684,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-modern-8bc81ca90f-20240531";
exports.version = "19.0.0-www-modern-28fe581bac-20240531";
@@ -688,7 +688,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-classic-8bc81ca90f-20240531";
exports.version = "19.0.0-www-classic-28fe581bac-20240531";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -688,7 +688,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-modern-8bc81ca90f-20240531";
exports.version = "19.0.0-www-modern-28fe581bac-20240531";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -60,7 +60,7 @@ function _assertThisInitialized(self) {
return self;
}
var ReactVersion = '19.0.0-www-classic-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-classic-28fe581bac-20240531';
var LegacyRoot = 0;
var ConcurrentRoot = 1;
+1 -1
View File
@@ -60,7 +60,7 @@ function _assertThisInitialized(self) {
return self;
}
var ReactVersion = '19.0.0-www-modern-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-modern-28fe581bac-20240531';
var LegacyRoot = 0;
var ConcurrentRoot = 1;
@@ -10640,7 +10640,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "19.0.0-www-classic-8bc81ca90f-20240531",
version: "19.0.0-www-classic-28fe581bac-20240531",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1370 = {
@@ -10671,7 +10671,7 @@ var internals$jscomp$inline_1370 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-classic-28fe581bac-20240531"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1371 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -10115,7 +10115,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "19.0.0-www-modern-8bc81ca90f-20240531",
version: "19.0.0-www-modern-28fe581bac-20240531",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1356 = {
@@ -10146,7 +10146,7 @@ var internals$jscomp$inline_1356 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-modern-28fe581bac-20240531"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1357 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -31059,7 +31059,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}
var ReactVersion = '19.0.0-www-classic-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-classic-28fe581bac-20240531';
function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
implementation) {
+1 -1
View File
@@ -30236,7 +30236,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}
var ReactVersion = '19.0.0-www-modern-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-modern-28fe581bac-20240531';
function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
implementation) {
@@ -17046,14 +17046,14 @@ function getCrossOriginStringAs(as, input) {
}
var isomorphicReactPackageVersion$jscomp$inline_1753 = React.version;
if (
"19.0.0-www-classic-8bc81ca90f-20240531" !==
"19.0.0-www-classic-28fe581bac-20240531" !==
isomorphicReactPackageVersion$jscomp$inline_1753
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1753,
"19.0.0-www-classic-8bc81ca90f-20240531"
"19.0.0-www-classic-28fe581bac-20240531"
)
);
Internals.findDOMNode = function (componentOrElement) {
@@ -17072,7 +17072,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1760 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-classic-8bc81ca90f-20240531",
version: "19.0.0-www-classic-28fe581bac-20240531",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2204 = {
@@ -17102,7 +17102,7 @@ var internals$jscomp$inline_2204 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-classic-28fe581bac-20240531"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2205 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17606,4 +17606,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-www-classic-8bc81ca90f-20240531";
exports.version = "19.0.0-www-classic-28fe581bac-20240531";
@@ -16409,14 +16409,14 @@ function getCrossOriginStringAs(as, input) {
}
var isomorphicReactPackageVersion$jscomp$inline_1724 = React.version;
if (
"19.0.0-www-modern-8bc81ca90f-20240531" !==
"19.0.0-www-modern-28fe581bac-20240531" !==
isomorphicReactPackageVersion$jscomp$inline_1724
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1724,
"19.0.0-www-modern-8bc81ca90f-20240531"
"19.0.0-www-modern-28fe581bac-20240531"
)
);
Internals.findDOMNode = function (componentOrElement) {
@@ -16435,7 +16435,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1726 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-modern-8bc81ca90f-20240531",
version: "19.0.0-www-modern-28fe581bac-20240531",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2195 = {
@@ -16465,7 +16465,7 @@ var internals$jscomp$inline_2195 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-modern-28fe581bac-20240531"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2196 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16839,4 +16839,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-www-modern-8bc81ca90f-20240531";
exports.version = "19.0.0-www-modern-28fe581bac-20240531";
@@ -17815,14 +17815,14 @@ function getCrossOriginStringAs(as, input) {
}
var isomorphicReactPackageVersion$jscomp$inline_1840 = React.version;
if (
"19.0.0-www-classic-8bc81ca90f-20240531" !==
"19.0.0-www-classic-28fe581bac-20240531" !==
isomorphicReactPackageVersion$jscomp$inline_1840
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1840,
"19.0.0-www-classic-8bc81ca90f-20240531"
"19.0.0-www-classic-28fe581bac-20240531"
)
);
Internals.findDOMNode = function (componentOrElement) {
@@ -17841,7 +17841,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1847 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-classic-8bc81ca90f-20240531",
version: "19.0.0-www-classic-28fe581bac-20240531",
rendererPackageName: "react-dom"
};
(function (internals) {
@@ -17885,7 +17885,7 @@ var devToolsConfig$jscomp$inline_1847 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-classic-28fe581bac-20240531"
});
function ReactDOMRoot(internalRoot) {
this._internalRoot = internalRoot;
@@ -18376,7 +18376,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-www-classic-8bc81ca90f-20240531";
exports.version = "19.0.0-www-classic-28fe581bac-20240531";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -17161,14 +17161,14 @@ function getCrossOriginStringAs(as, input) {
}
var isomorphicReactPackageVersion$jscomp$inline_1811 = React.version;
if (
"19.0.0-www-modern-8bc81ca90f-20240531" !==
"19.0.0-www-modern-28fe581bac-20240531" !==
isomorphicReactPackageVersion$jscomp$inline_1811
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1811,
"19.0.0-www-modern-8bc81ca90f-20240531"
"19.0.0-www-modern-28fe581bac-20240531"
)
);
Internals.findDOMNode = function (componentOrElement) {
@@ -17187,7 +17187,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1813 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-modern-8bc81ca90f-20240531",
version: "19.0.0-www-modern-28fe581bac-20240531",
rendererPackageName: "react-dom"
};
(function (internals) {
@@ -17231,7 +17231,7 @@ var devToolsConfig$jscomp$inline_1813 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-modern-28fe581bac-20240531"
});
function ReactDOMRoot(internalRoot) {
this._internalRoot = internalRoot;
@@ -17592,7 +17592,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-www-modern-8bc81ca90f-20240531";
exports.version = "19.0.0-www-modern-28fe581bac-20240531";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require('react');
var ReactDOM = require('react-dom');
var ReactVersion = '19.0.0-www-classic-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-classic-28fe581bac-20240531';
// This refers to a WWW module.
var warningWWW = require('warning');
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require('react');
var ReactDOM = require('react-dom');
var ReactVersion = '19.0.0-www-modern-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-modern-28fe581bac-20240531';
// This refers to a WWW module.
var warningWWW = require('warning');
@@ -5699,4 +5699,4 @@ exports.renderToString = function (children, options) {
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
);
};
exports.version = "19.0.0-www-classic-8bc81ca90f-20240531";
exports.version = "19.0.0-www-classic-28fe581bac-20240531";
@@ -5677,4 +5677,4 @@ exports.renderToString = function (children, options) {
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
);
};
exports.version = "19.0.0-www-modern-8bc81ca90f-20240531";
exports.version = "19.0.0-www-modern-28fe581bac-20240531";
@@ -31625,7 +31625,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}
var ReactVersion = '19.0.0-www-classic-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-classic-28fe581bac-20240531';
function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
implementation) {
@@ -30802,7 +30802,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}
var ReactVersion = '19.0.0-www-modern-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-modern-28fe581bac-20240531';
function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
implementation) {
@@ -17375,14 +17375,14 @@ function getCrossOriginStringAs(as, input) {
}
var isomorphicReactPackageVersion$jscomp$inline_1783 = React.version;
if (
"19.0.0-www-classic-8bc81ca90f-20240531" !==
"19.0.0-www-classic-28fe581bac-20240531" !==
isomorphicReactPackageVersion$jscomp$inline_1783
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1783,
"19.0.0-www-classic-8bc81ca90f-20240531"
"19.0.0-www-classic-28fe581bac-20240531"
)
);
Internals.findDOMNode = function (componentOrElement) {
@@ -17401,7 +17401,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1790 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-classic-8bc81ca90f-20240531",
version: "19.0.0-www-classic-28fe581bac-20240531",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2239 = {
@@ -17431,7 +17431,7 @@ var internals$jscomp$inline_2239 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-classic-28fe581bac-20240531"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2240 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -18086,4 +18086,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-www-classic-8bc81ca90f-20240531";
exports.version = "19.0.0-www-classic-28fe581bac-20240531";
@@ -16797,14 +16797,14 @@ function getCrossOriginStringAs(as, input) {
}
var isomorphicReactPackageVersion$jscomp$inline_1754 = React.version;
if (
"19.0.0-www-modern-8bc81ca90f-20240531" !==
"19.0.0-www-modern-28fe581bac-20240531" !==
isomorphicReactPackageVersion$jscomp$inline_1754
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1754,
"19.0.0-www-modern-8bc81ca90f-20240531"
"19.0.0-www-modern-28fe581bac-20240531"
)
);
Internals.findDOMNode = function (componentOrElement) {
@@ -16823,7 +16823,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1756 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-modern-8bc81ca90f-20240531",
version: "19.0.0-www-modern-28fe581bac-20240531",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2230 = {
@@ -16853,7 +16853,7 @@ var internals$jscomp$inline_2230 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-modern-28fe581bac-20240531"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2231 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17378,4 +17378,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-www-modern-8bc81ca90f-20240531";
exports.version = "19.0.0-www-modern-28fe581bac-20240531";
@@ -28827,7 +28827,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}
var ReactVersion = '19.0.0-www-classic-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-classic-28fe581bac-20240531';
/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
@@ -28095,7 +28095,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}
var ReactVersion = '19.0.0-www-modern-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-modern-28fe581bac-20240531';
/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
@@ -12636,7 +12636,7 @@ module.exports = function ($$$config) {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-classic-28fe581bac-20240531"
};
if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)
devToolsConfig = !1;
@@ -12149,7 +12149,7 @@ module.exports = function ($$$config) {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-8bc81ca90f-20240531"
reconcilerVersion: "19.0.0-www-modern-28fe581bac-20240531"
};
if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)
devToolsConfig = !1;
@@ -23313,7 +23313,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}
var ReactVersion = '19.0.0-www-classic-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-classic-28fe581bac-20240531';
/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
@@ -23313,7 +23313,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}
var ReactVersion = '19.0.0-www-modern-8bc81ca90f-20240531';
var ReactVersion = '19.0.0-www-modern-28fe581bac-20240531';
/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol