mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add flag to disable caching behavior of React.cache on the client (#28250)
Adds a feature flag to control whether the client cache function is just
a passthrough. before we land breaking changes for the next major it
will be off and then we can flag it on when we want to break it.
flag is off for OSS for now and on elsewhere (though the parent flag
enableCache is off in some cases)
DiffTrain build for [2bc7d336ae](https://github.com/facebook/react/commit/2bc7d336ae7db689699baeb1fffc2c03d8753ffe)
This commit is contained in:
@@ -1 +1 @@
|
||||
472854820bfd0058dfc85524051171c7b7c998c1
|
||||
2bc7d336ae7db689699baeb1fffc2c03d8753ffe
|
||||
|
||||
@@ -24,7 +24,7 @@ if (__DEV__) {
|
||||
) {
|
||||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
||||
}
|
||||
var ReactVersion = "18.3.0-www-classic-82bfc644";
|
||||
var ReactVersion = "18.3.0-www-classic-14d23768";
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
@@ -2776,22 +2776,24 @@ if (__DEV__) {
|
||||
}
|
||||
|
||||
function cache(fn) {
|
||||
// On the client (i.e. not a Server Components environment) `cache` has
|
||||
// no caching behavior. We just return the function as-is.
|
||||
//
|
||||
// We intend to implement client caching in a future major release. In the
|
||||
// meantime, it's only exposed as an API so that Shared Components can use
|
||||
// per-request caching on the server without breaking on the client. But it
|
||||
// does mean they need to be aware of the behavioral difference.
|
||||
//
|
||||
// The rest of the behavior is the same as the server implementation — it
|
||||
// returns a new reference, extra properties like `displayName` are not
|
||||
// preserved, the length of the new function is 0, etc. That way apps can't
|
||||
// accidentally depend on those details.
|
||||
return function () {
|
||||
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
|
||||
return fn.apply(null, arguments);
|
||||
};
|
||||
{
|
||||
// On the client (i.e. not a Server Components environment) `cache` has
|
||||
// no caching behavior. We just return the function as-is.
|
||||
//
|
||||
// We intend to implement client caching in a future major release. In the
|
||||
// meantime, it's only exposed as an API so that Shared Components can use
|
||||
// per-request caching on the server without breaking on the client. But it
|
||||
// does mean they need to be aware of the behavioral difference.
|
||||
//
|
||||
// The rest of the behavior is the same as the server implementation — it
|
||||
// returns a new reference, extra properties like `displayName` are not
|
||||
// preserved, the length of the new function is 0, etc. That way apps can't
|
||||
// accidentally depend on those details.
|
||||
return function () {
|
||||
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
|
||||
return fn.apply(null, arguments);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function resolveDispatcher() {
|
||||
|
||||
@@ -24,7 +24,7 @@ if (__DEV__) {
|
||||
) {
|
||||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
||||
}
|
||||
var ReactVersion = "18.3.0-www-modern-00e8e94b";
|
||||
var ReactVersion = "18.3.0-www-modern-7437533c";
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
@@ -2741,22 +2741,24 @@ if (__DEV__) {
|
||||
}
|
||||
|
||||
function cache(fn) {
|
||||
// On the client (i.e. not a Server Components environment) `cache` has
|
||||
// no caching behavior. We just return the function as-is.
|
||||
//
|
||||
// We intend to implement client caching in a future major release. In the
|
||||
// meantime, it's only exposed as an API so that Shared Components can use
|
||||
// per-request caching on the server without breaking on the client. But it
|
||||
// does mean they need to be aware of the behavioral difference.
|
||||
//
|
||||
// The rest of the behavior is the same as the server implementation — it
|
||||
// returns a new reference, extra properties like `displayName` are not
|
||||
// preserved, the length of the new function is 0, etc. That way apps can't
|
||||
// accidentally depend on those details.
|
||||
return function () {
|
||||
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
|
||||
return fn.apply(null, arguments);
|
||||
};
|
||||
{
|
||||
// On the client (i.e. not a Server Components environment) `cache` has
|
||||
// no caching behavior. We just return the function as-is.
|
||||
//
|
||||
// We intend to implement client caching in a future major release. In the
|
||||
// meantime, it's only exposed as an API so that Shared Components can use
|
||||
// per-request caching on the server without breaking on the client. But it
|
||||
// does mean they need to be aware of the behavioral difference.
|
||||
//
|
||||
// The rest of the behavior is the same as the server implementation — it
|
||||
// returns a new reference, extra properties like `displayName` are not
|
||||
// preserved, the length of the new function is 0, etc. That way apps can't
|
||||
// accidentally depend on those details.
|
||||
return function () {
|
||||
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
|
||||
return fn.apply(null, arguments);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function resolveDispatcher() {
|
||||
|
||||
Reference in New Issue
Block a user