Skip to content

Commit b72ef1a

Browse files
committed
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 [2bc7d33](2bc7d33)
1 parent c178d6f commit b72ef1a

File tree

3 files changed

+39
-35
lines changed

3 files changed

+39
-35
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
472854820bfd0058dfc85524051171c7b7c998c1
1+
2bc7d336ae7db689699baeb1fffc2c03d8753ffe

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-www-classic-82bfc644";
27+
var ReactVersion = "18.3.0-www-classic-14d23768";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,
@@ -2776,22 +2776,24 @@ if (__DEV__) {
27762776
}
27772777

27782778
function cache(fn) {
2779-
// On the client (i.e. not a Server Components environment) `cache` has
2780-
// no caching behavior. We just return the function as-is.
2781-
//
2782-
// We intend to implement client caching in a future major release. In the
2783-
// meantime, it's only exposed as an API so that Shared Components can use
2784-
// per-request caching on the server without breaking on the client. But it
2785-
// does mean they need to be aware of the behavioral difference.
2786-
//
2787-
// The rest of the behavior is the same as the server implementation — it
2788-
// returns a new reference, extra properties like `displayName` are not
2789-
// preserved, the length of the new function is 0, etc. That way apps can't
2790-
// accidentally depend on those details.
2791-
return function () {
2792-
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
2793-
return fn.apply(null, arguments);
2794-
};
2779+
{
2780+
// On the client (i.e. not a Server Components environment) `cache` has
2781+
// no caching behavior. We just return the function as-is.
2782+
//
2783+
// We intend to implement client caching in a future major release. In the
2784+
// meantime, it's only exposed as an API so that Shared Components can use
2785+
// per-request caching on the server without breaking on the client. But it
2786+
// does mean they need to be aware of the behavioral difference.
2787+
//
2788+
// The rest of the behavior is the same as the server implementation — it
2789+
// returns a new reference, extra properties like `displayName` are not
2790+
// preserved, the length of the new function is 0, etc. That way apps can't
2791+
// accidentally depend on those details.
2792+
return function () {
2793+
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
2794+
return fn.apply(null, arguments);
2795+
};
2796+
}
27952797
}
27962798

27972799
function resolveDispatcher() {

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-www-modern-00e8e94b";
27+
var ReactVersion = "18.3.0-www-modern-7437533c";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,
@@ -2741,22 +2741,24 @@ if (__DEV__) {
27412741
}
27422742

27432743
function cache(fn) {
2744-
// On the client (i.e. not a Server Components environment) `cache` has
2745-
// no caching behavior. We just return the function as-is.
2746-
//
2747-
// We intend to implement client caching in a future major release. In the
2748-
// meantime, it's only exposed as an API so that Shared Components can use
2749-
// per-request caching on the server without breaking on the client. But it
2750-
// does mean they need to be aware of the behavioral difference.
2751-
//
2752-
// The rest of the behavior is the same as the server implementation — it
2753-
// returns a new reference, extra properties like `displayName` are not
2754-
// preserved, the length of the new function is 0, etc. That way apps can't
2755-
// accidentally depend on those details.
2756-
return function () {
2757-
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
2758-
return fn.apply(null, arguments);
2759-
};
2744+
{
2745+
// On the client (i.e. not a Server Components environment) `cache` has
2746+
// no caching behavior. We just return the function as-is.
2747+
//
2748+
// We intend to implement client caching in a future major release. In the
2749+
// meantime, it's only exposed as an API so that Shared Components can use
2750+
// per-request caching on the server without breaking on the client. But it
2751+
// does mean they need to be aware of the behavioral difference.
2752+
//
2753+
// The rest of the behavior is the same as the server implementation — it
2754+
// returns a new reference, extra properties like `displayName` are not
2755+
// preserved, the length of the new function is 0, etc. That way apps can't
2756+
// accidentally depend on those details.
2757+
return function () {
2758+
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
2759+
return fn.apply(null, arguments);
2760+
};
2761+
}
27602762
}
27612763

27622764
function resolveDispatcher() {

0 commit comments

Comments
 (0)