diff --git a/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js b/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
index 4444076681208..30b5ced5cf2e3 100644
--- a/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
+++ b/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
@@ -537,7 +537,6 @@ describe('ReactCompositeComponent', () => {
});
it('should cleanup even if render() fatals', async () => {
- const dispatcherEnabled = __DEV__ || gate(flags => flags.enableCache);
const ownerEnabled = __DEV__;
let stashedDispatcher;
@@ -551,7 +550,7 @@ describe('ReactCompositeComponent', () => {
}
const instance = ;
- expect(ReactSharedInternals.A).toBe(dispatcherEnabled ? null : undefined);
+ expect(ReactSharedInternals.A).toBe(null);
const root = ReactDOMClient.createRoot(document.createElement('div'));
await expect(async () => {
@@ -560,15 +559,11 @@ describe('ReactCompositeComponent', () => {
});
}).rejects.toThrow();
- expect(ReactSharedInternals.A).toBe(dispatcherEnabled ? null : undefined);
- if (dispatcherEnabled) {
- if (ownerEnabled) {
- expect(stashedDispatcher.getOwner()).toBe(null);
- } else {
- expect(stashedDispatcher.getOwner).toBe(undefined);
- }
+ expect(ReactSharedInternals.A).toBe(null);
+ if (ownerEnabled) {
+ expect(stashedDispatcher.getOwner()).toBe(null);
} else {
- expect(stashedDispatcher).toBe(undefined);
+ expect(stashedDispatcher.getOwner).toBe(undefined);
}
});
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationModes-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationModes-test.js
index 9dbac22704d17..5770bd1e20c9f 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationModes-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationModes-test.js
@@ -37,56 +37,6 @@ describe('ReactDOMServerIntegration', () => {
resetModules();
});
- // Test pragmas don't support itRenders abstraction
- if (
- __EXPERIMENTAL__ &&
- require('shared/ReactFeatureFlags').enableDebugTracing
- ) {
- describe('React.unstable_DebugTracingMode', () => {
- beforeEach(() => {
- spyOnDevAndProd(console, 'log');
- });
-
- itRenders('with one child', async render => {
- const e = await render(
-
- text1
- ,
- );
- const parent = e.parentNode;
- expect(parent.childNodes[0].tagName).toBe('DIV');
- });
-
- itRenders('mode with several children', async render => {
- const Header = props => {
- return
header
;
- };
- const Footer = props => {
- return (
-
- footer
- about
-
- );
- };
- const e = await render(
-
- text1
- text2
-
-
- ,
- );
- const parent = e.parentNode;
- expect(parent.childNodes[0].tagName).toBe('DIV');
- expect(parent.childNodes[1].tagName).toBe('SPAN');
- expect(parent.childNodes[2].tagName).toBe('P');
- expect(parent.childNodes[3].tagName).toBe('H2');
- expect(parent.childNodes[4].tagName).toBe('H3');
- });
- });
- }
-
describe('React.StrictMode', () => {
itRenders('a strict mode with one child', async render => {
const e = await render(
diff --git a/packages/react-markup/src/__tests__/ReactMarkupServer-test.js b/packages/react-markup/src/__tests__/ReactMarkupServer-test.js
index 1e0cce3c9a150..afd6ea5df8f26 100644
--- a/packages/react-markup/src/__tests__/ReactMarkupServer-test.js
+++ b/packages/react-markup/src/__tests__/ReactMarkupServer-test.js
@@ -209,7 +209,6 @@ if (!__EXPERIMENTAL__) {
);
});
- // @gate enableCache
it('supports cache', async () => {
let counter = 0;
const getCount = React.cache(() => {
diff --git a/packages/react-reconciler/src/DebugTracing.js b/packages/react-reconciler/src/DebugTracing.js
deleted file mode 100644
index 16606748be696..0000000000000
--- a/packages/react-reconciler/src/DebugTracing.js
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @flow
- */
-
-import type {Lane, Lanes} from './ReactFiberLane';
-import type {Wakeable} from 'shared/ReactTypes';
-
-import {enableDebugTracing} from 'shared/ReactFeatureFlags';
-
-const nativeConsole: Object = console;
-let nativeConsoleLog: null | Function = null;
-
-const pendingGroupArgs: Array = [];
-let printedGroupIndex: number = -1;
-
-function formatLanes(laneOrLanes: Lane | Lanes): string {
- return '0b' + (laneOrLanes: any).toString(2).padStart(31, '0');
-}
-
-function group(...groupArgs: Array): void {
- pendingGroupArgs.push(groupArgs);
-
- if (nativeConsoleLog === null) {
- nativeConsoleLog = nativeConsole.log;
- nativeConsole.log = log;
- }
-}
-
-function groupEnd(): void {
- pendingGroupArgs.pop();
- while (printedGroupIndex >= pendingGroupArgs.length) {
- nativeConsole.groupEnd();
- printedGroupIndex--;
- }
-
- if (pendingGroupArgs.length === 0) {
- nativeConsole.log = nativeConsoleLog;
- nativeConsoleLog = null;
- }
-}
-
-function log(...logArgs: Array): void {
- if (printedGroupIndex < pendingGroupArgs.length - 1) {
- for (let i = printedGroupIndex + 1; i < pendingGroupArgs.length; i++) {
- const groupArgs = pendingGroupArgs[i];
- nativeConsole.group(...groupArgs);
- }
- printedGroupIndex = pendingGroupArgs.length - 1;
- }
- if (typeof nativeConsoleLog === 'function') {
- nativeConsoleLog(...logArgs);
- } else {
- nativeConsole.log(...logArgs);
- }
-}
-
-const REACT_LOGO_STYLE =
- 'background-color: #20232a; color: #61dafb; padding: 0 2px;';
-
-export function logCommitStarted(lanes: Lanes): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- group(
- `%c⚛%c commit%c (${formatLanes(lanes)})`,
- REACT_LOGO_STYLE,
- '',
- 'font-weight: normal;',
- );
- }
- }
-}
-
-export function logCommitStopped(): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- groupEnd();
- }
- }
-}
-
-const PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
-// $FlowFixMe[incompatible-type]: Flow cannot handle polymorphic WeakMaps
-const wakeableIDs: WeakMap = new PossiblyWeakMap();
-let wakeableID: number = 0;
-function getWakeableID(wakeable: Wakeable): number {
- if (!wakeableIDs.has(wakeable)) {
- wakeableIDs.set(wakeable, wakeableID++);
- }
- return ((wakeableIDs.get(wakeable): any): number);
-}
-
-export function logComponentSuspended(
- componentName: string,
- wakeable: Wakeable,
-): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- const id = getWakeableID(wakeable);
- const display = (wakeable: any).displayName || wakeable;
- log(
- `%c⚛%c ${componentName} suspended`,
- REACT_LOGO_STYLE,
- 'color: #80366d; font-weight: bold;',
- id,
- display,
- );
- wakeable.then(
- () => {
- log(
- `%c⚛%c ${componentName} resolved`,
- REACT_LOGO_STYLE,
- 'color: #80366d; font-weight: bold;',
- id,
- display,
- );
- },
- () => {
- log(
- `%c⚛%c ${componentName} rejected`,
- REACT_LOGO_STYLE,
- 'color: #80366d; font-weight: bold;',
- id,
- display,
- );
- },
- );
- }
- }
-}
-
-export function logLayoutEffectsStarted(lanes: Lanes): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- group(
- `%c⚛%c layout effects%c (${formatLanes(lanes)})`,
- REACT_LOGO_STYLE,
- '',
- 'font-weight: normal;',
- );
- }
- }
-}
-
-export function logLayoutEffectsStopped(): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- groupEnd();
- }
- }
-}
-
-export function logPassiveEffectsStarted(lanes: Lanes): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- group(
- `%c⚛%c passive effects%c (${formatLanes(lanes)})`,
- REACT_LOGO_STYLE,
- '',
- 'font-weight: normal;',
- );
- }
- }
-}
-
-export function logPassiveEffectsStopped(): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- groupEnd();
- }
- }
-}
-
-export function logRenderStarted(lanes: Lanes): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- group(
- `%c⚛%c render%c (${formatLanes(lanes)})`,
- REACT_LOGO_STYLE,
- '',
- 'font-weight: normal;',
- );
- }
- }
-}
-
-export function logRenderStopped(): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- groupEnd();
- }
- }
-}
-
-export function logForceUpdateScheduled(
- componentName: string,
- lane: Lane,
-): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- log(
- `%c⚛%c ${componentName} forced update %c(${formatLanes(lane)})`,
- REACT_LOGO_STYLE,
- 'color: #db2e1f; font-weight: bold;',
- '',
- );
- }
- }
-}
-
-export function logStateUpdateScheduled(
- componentName: string,
- lane: Lane,
- payloadOrAction: any,
-): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- log(
- `%c⚛%c ${componentName} updated state %c(${formatLanes(lane)})`,
- REACT_LOGO_STYLE,
- 'color: #01a252; font-weight: bold;',
- '',
- payloadOrAction,
- );
- }
- }
-}
diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js
index 29a8931038c8d..42f347f4ba956 100644
--- a/packages/react-reconciler/src/ReactFiber.js
+++ b/packages/react-reconciler/src/ReactFiber.js
@@ -32,7 +32,6 @@ import {
enableScopeAPI,
enableLegacyHidden,
enableTransitionTracing,
- enableDebugTracing,
enableDO_NOT_USE_disableStrictPassiveEffect,
enableRenderableContext,
disableLegacyMode,
@@ -80,7 +79,6 @@ import {NoLanes} from './ReactFiberLane';
import {
NoMode,
ConcurrentMode,
- DebugTracingMode,
ProfileMode,
StrictLegacyMode,
StrictEffectsMode,
@@ -89,7 +87,6 @@ import {
import {
REACT_FORWARD_REF_TYPE,
REACT_FRAGMENT_TYPE,
- REACT_DEBUG_TRACING_MODE_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_PROFILER_TYPE,
REACT_PROVIDER_TYPE,
@@ -630,13 +627,6 @@ export function createFiberFromTypeAndProps(
return createFiberFromTracingMarker(pendingProps, mode, lanes, key);
}
// Fall through
- case REACT_DEBUG_TRACING_MODE_TYPE:
- if (enableDebugTracing) {
- fiberTag = Mode;
- mode |= DebugTracingMode;
- break;
- }
- // Fall through
default: {
if (typeof type === 'object' && type !== null) {
switch (type.$$typeof) {
diff --git a/packages/react-reconciler/src/ReactFiberAsyncDispatcher.js b/packages/react-reconciler/src/ReactFiberAsyncDispatcher.js
index 0d6856f5d0ac1..4ff65fb90011a 100644
--- a/packages/react-reconciler/src/ReactFiberAsyncDispatcher.js
+++ b/packages/react-reconciler/src/ReactFiberAsyncDispatcher.js
@@ -10,16 +10,12 @@
import type {AsyncDispatcher, Fiber} from './ReactInternalTypes';
import type {Cache} from './ReactFiberCacheComponent';
-import {enableCache} from 'shared/ReactFeatureFlags';
import {readContext} from './ReactFiberNewContext';
import {CacheContext} from './ReactFiberCacheComponent';
import {current as currentOwner} from './ReactCurrentFiber';
function getCacheForType(resourceType: () => T): T {
- if (!enableCache) {
- throw new Error('Not implemented.');
- }
const cache: Cache = readContext(CacheContext);
let cacheForType: T | void = (cache.data.get(resourceType): any);
if (cacheForType === undefined) {
diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index 0ae0e668d22ac..2d3e3c04c48ea 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -100,7 +100,6 @@ import {
enableProfilerCommitHooks,
enableProfilerTimer,
enableScopeAPI,
- enableCache,
enableLazyContextPropagation,
enableSchedulingProfiler,
enableTransitionTracing,
@@ -714,12 +713,10 @@ function updateOffscreenComponent(
cachePool: null,
};
workInProgress.memoizedState = nextState;
- if (enableCache) {
- // push the cache pool even though we're going to bail out
- // because otherwise there'd be a context mismatch
- if (current !== null) {
- pushTransition(workInProgress, null, null);
- }
+ // push the cache pool even though we're going to bail out
+ // because otherwise there'd be a context mismatch
+ if (current !== null) {
+ pushTransition(workInProgress, null, null);
}
reuseHiddenContextOnStack(workInProgress);
pushOffscreenSuspenseHandler(workInProgress);
@@ -753,7 +750,7 @@ function updateOffscreenComponent(
cachePool: null,
};
workInProgress.memoizedState = nextState;
- if (enableCache && current !== null) {
+ if (current !== null) {
// If the render that spawned this one accessed the cache pool, resume
// using the same cache. Unless the parent changed, since that means
// there was a refresh.
@@ -776,12 +773,10 @@ function updateOffscreenComponent(
if (prevState !== null) {
// We're going from hidden -> visible.
let prevCachePool = null;
- if (enableCache) {
- // If the render that spawned this one accessed the cache pool, resume
- // using the same cache. Unless the parent changed, since that means
- // there was a refresh.
- prevCachePool = prevState.cachePool;
- }
+ // If the render that spawned this one accessed the cache pool, resume
+ // using the same cache. Unless the parent changed, since that means
+ // there was a refresh.
+ prevCachePool = prevState.cachePool;
let transitions = null;
if (enableTransitionTracing) {
@@ -806,13 +801,11 @@ function updateOffscreenComponent(
// special to do. Need to push to the stack regardless, though, to avoid
// a push/pop misalignment.
- if (enableCache) {
- // If the render that spawned this one accessed the cache pool, resume
- // using the same cache. Unless the parent changed, since that means
- // there was a refresh.
- if (current !== null) {
- pushTransition(workInProgress, null, null);
- }
+ // If the render that spawned this one accessed the cache pool, resume
+ // using the same cache. Unless the parent changed, since that means
+ // there was a refresh.
+ if (current !== null) {
+ pushTransition(workInProgress, null, null);
}
// We're about to bail out, but we need to push this to the stack anyway
@@ -835,15 +828,13 @@ function deferHiddenOffscreenComponent(
const nextState: OffscreenState = {
baseLanes: nextBaseLanes,
// Save the cache pool so we can resume later.
- cachePool: enableCache ? getOffscreenDeferredCache() : null,
+ cachePool: getOffscreenDeferredCache(),
};
workInProgress.memoizedState = nextState;
- if (enableCache) {
- // push the cache pool even though we're going to bail out
- // because otherwise there'd be a context mismatch
- if (current !== null) {
- pushTransition(workInProgress, null, null);
- }
+ // push the cache pool even though we're going to bail out
+ // because otherwise there'd be a context mismatch
+ if (current !== null) {
+ pushTransition(workInProgress, null, null);
}
// We're about to bail out, but we need to push this to the stack anyway
@@ -876,10 +867,6 @@ function updateCacheComponent(
workInProgress: Fiber,
renderLanes: Lanes,
) {
- if (!enableCache) {
- return null;
- }
-
prepareToReadContext(workInProgress, renderLanes);
const parentCache = readContext(CacheContext);
@@ -1480,13 +1467,11 @@ function updateHostRoot(
pushRootMarkerInstance(workInProgress);
}
- if (enableCache) {
- const nextCache: Cache = nextState.cache;
- pushCacheProvider(workInProgress, nextCache);
- if (nextCache !== prevState.cache) {
- // The root cache refreshed.
- propagateContextChange(workInProgress, CacheContext, renderLanes);
- }
+ const nextCache: Cache = nextState.cache;
+ pushCacheProvider(workInProgress, nextCache);
+ if (nextCache !== prevState.cache) {
+ // The root cache refreshed.
+ propagateContextChange(workInProgress, CacheContext, renderLanes);
}
// This would ideally go inside processUpdateQueue, but because it suspends,
@@ -1990,28 +1975,26 @@ function updateSuspenseOffscreenState(
renderLanes: Lanes,
): OffscreenState {
let cachePool: SpawnedCachePool | null = null;
- if (enableCache) {
- const prevCachePool: SpawnedCachePool | null = prevOffscreenState.cachePool;
- if (prevCachePool !== null) {
- const parentCache = isPrimaryRenderer
- ? CacheContext._currentValue
- : CacheContext._currentValue2;
- if (prevCachePool.parent !== parentCache) {
- // Detected a refresh in the parent. This overrides any previously
- // suspended cache.
- cachePool = {
- parent: parentCache,
- pool: parentCache,
- };
- } else {
- // We can reuse the cache from last time. The only thing that would have
- // overridden it is a parent refresh, which we checked for above.
- cachePool = prevCachePool;
- }
+ const prevCachePool: SpawnedCachePool | null = prevOffscreenState.cachePool;
+ if (prevCachePool !== null) {
+ const parentCache = isPrimaryRenderer
+ ? CacheContext._currentValue
+ : CacheContext._currentValue2;
+ if (prevCachePool.parent !== parentCache) {
+ // Detected a refresh in the parent. This overrides any previously
+ // suspended cache.
+ cachePool = {
+ parent: parentCache,
+ pool: parentCache,
+ };
} else {
- // If there's no previous cache pool, grab the current one.
- cachePool = getSuspendedCache();
+ // We can reuse the cache from last time. The only thing that would have
+ // overridden it is a parent refresh, which we checked for above.
+ cachePool = prevCachePool;
}
+ } else {
+ // If there's no previous cache pool, grab the current one.
+ cachePool = getSuspendedCache();
}
return {
baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes),
@@ -3599,7 +3582,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
// the begin phase. There's still some bookkeeping we that needs to be done
// in this optimized path, mostly pushing stuff onto the stack.
switch (workInProgress.tag) {
- case HostRoot:
+ case HostRoot: {
pushHostRootContext(workInProgress);
const root: FiberRoot = workInProgress.stateNode;
pushRootTransition(workInProgress, root, renderLanes);
@@ -3608,12 +3591,11 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
pushRootMarkerInstance(workInProgress);
}
- if (enableCache) {
- const cache: Cache = current.memoizedState.cache;
- pushCacheProvider(workInProgress, cache);
- }
+ const cache: Cache = current.memoizedState.cache;
+ pushCacheProvider(workInProgress, cache);
resetHydrationState();
break;
+ }
case HostSingleton:
case HostComponent:
pushHostContext(workInProgress);
@@ -3795,10 +3777,8 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
return updateOffscreenComponent(current, workInProgress, renderLanes);
}
case CacheComponent: {
- if (enableCache) {
- const cache: Cache = current.memoizedState.cache;
- pushCacheProvider(workInProgress, cache);
- }
+ const cache: Cache = current.memoizedState.cache;
+ pushCacheProvider(workInProgress, cache);
break;
}
case TracingMarkerComponent: {
@@ -4085,10 +4065,7 @@ function beginWork(
break;
}
case CacheComponent: {
- if (enableCache) {
- return updateCacheComponent(current, workInProgress, renderLanes);
- }
- break;
+ return updateCacheComponent(current, workInProgress, renderLanes);
}
case TracingMarkerComponent: {
if (enableTransitionTracing) {
diff --git a/packages/react-reconciler/src/ReactFiberCacheComponent.js b/packages/react-reconciler/src/ReactFiberCacheComponent.js
index 64269c5785d13..c7e0c1a11d783 100644
--- a/packages/react-reconciler/src/ReactFiberCacheComponent.js
+++ b/packages/react-reconciler/src/ReactFiberCacheComponent.js
@@ -10,7 +10,6 @@
import type {ReactContext} from 'shared/ReactTypes';
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
-import {enableCache} from 'shared/ReactFeatureFlags';
import {REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
import {pushProvider, popProvider} from './ReactFiberNewContext';
@@ -18,8 +17,8 @@ import * as Scheduler from 'scheduler';
// In environments without AbortController (e.g. tests)
// replace it with a lightweight shim that only has the features we use.
-const AbortControllerLocal: typeof AbortController = enableCache
- ? typeof AbortController !== 'undefined'
+const AbortControllerLocal: typeof AbortController =
+ typeof AbortController !== 'undefined'
? AbortController
: // $FlowFixMe[missing-this-annot]
// $FlowFixMe[prop-missing]
@@ -36,9 +35,7 @@ const AbortControllerLocal: typeof AbortController = enableCache
signal.aborted = true;
listeners.forEach(listener => listener());
};
- }
- : // $FlowFixMe[incompatible-type]
- null;
+ };
export type Cache = {
controller: AbortController,
@@ -63,20 +60,18 @@ const {
unstable_NormalPriority: NormalPriority,
} = Scheduler;
-export const CacheContext: ReactContext = enableCache
- ? {
- $$typeof: REACT_CONTEXT_TYPE,
- // We don't use Consumer/Provider for Cache components. So we'll cheat.
- Consumer: (null: any),
- Provider: (null: any),
- // We'll initialize these at the root.
- _currentValue: (null: any),
- _currentValue2: (null: any),
- _threadCount: 0,
- }
- : (null: any);
+export const CacheContext: ReactContext = {
+ $$typeof: REACT_CONTEXT_TYPE,
+ // We don't use Consumer/Provider for Cache components. So we'll cheat.
+ Consumer: (null: any),
+ Provider: (null: any),
+ // We'll initialize these at the root.
+ _currentValue: (null: any),
+ _currentValue2: (null: any),
+ _threadCount: 0,
+};
-if (__DEV__ && enableCache) {
+if (__DEV__) {
CacheContext._currentRenderer = null;
CacheContext._currentRenderer2 = null;
}
@@ -85,22 +80,14 @@ if (__DEV__ && enableCache) {
// for retaining the cache once it is in use (retainCache), and releasing the cache
// once it is no longer needed (releaseCache).
export function createCache(): Cache {
- if (!enableCache) {
- return (null: any);
- }
- const cache: Cache = {
+ return {
controller: new AbortControllerLocal(),
data: new Map(),
refCount: 0,
};
-
- return cache;
}
export function retainCache(cache: Cache) {
- if (!enableCache) {
- return;
- }
if (__DEV__) {
if (cache.controller.signal.aborted) {
console.warn(
@@ -114,9 +101,6 @@ export function retainCache(cache: Cache) {
// Cleanup a cache instance, potentially freeing it if there are no more references
export function releaseCache(cache: Cache) {
- if (!enableCache) {
- return;
- }
cache.refCount--;
if (__DEV__) {
if (cache.refCount < 0) {
@@ -134,15 +118,9 @@ export function releaseCache(cache: Cache) {
}
export function pushCacheProvider(workInProgress: Fiber, cache: Cache) {
- if (!enableCache) {
- return;
- }
pushProvider(workInProgress, CacheContext, cache);
}
export function popCacheProvider(workInProgress: Fiber, cache: Cache) {
- if (!enableCache) {
- return;
- }
popProvider(CacheContext, workInProgress);
}
diff --git a/packages/react-reconciler/src/ReactFiberClassComponent.js b/packages/react-reconciler/src/ReactFiberClassComponent.js
index c32525702e944..f5d5c96a2a93c 100644
--- a/packages/react-reconciler/src/ReactFiberClassComponent.js
+++ b/packages/react-reconciler/src/ReactFiberClassComponent.js
@@ -20,7 +20,6 @@ import {
import {
debugRenderPhaseSideEffectsForStrictMode,
disableLegacyContext,
- enableDebugTracing,
enableSchedulingProfiler,
enableLazyContextPropagation,
disableDefaultPropsExceptForClasses,
@@ -35,12 +34,7 @@ import assign from 'shared/assign';
import isArray from 'shared/isArray';
import {REACT_CONTEXT_TYPE, REACT_CONSUMER_TYPE} from 'shared/ReactSymbols';
-import {
- DebugTracingMode,
- NoMode,
- StrictLegacyMode,
- StrictEffectsMode,
-} from './ReactTypeOfMode';
+import {NoMode, StrictLegacyMode, StrictEffectsMode} from './ReactTypeOfMode';
import {
enqueueUpdate,
@@ -65,7 +59,6 @@ import {
} from './ReactFiberContext';
import {readContext, checkIfContextChanged} from './ReactFiberNewContext';
import {requestUpdateLane, scheduleUpdateOnFiber} from './ReactFiberWorkLoop';
-import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';
import {
markForceUpdateScheduled,
markStateUpdateScheduled,
@@ -199,15 +192,6 @@ const classComponentUpdater = {
entangleTransitions(root, fiber, lane);
}
- if (__DEV__) {
- if (enableDebugTracing) {
- if (fiber.mode & DebugTracingMode) {
- const name = getComponentNameFromFiber(fiber) || 'Unknown';
- logStateUpdateScheduled(name, lane, payload);
- }
- }
- }
-
if (enableSchedulingProfiler) {
markStateUpdateScheduled(fiber, lane);
}
@@ -234,15 +218,6 @@ const classComponentUpdater = {
entangleTransitions(root, fiber, lane);
}
- if (__DEV__) {
- if (enableDebugTracing) {
- if (fiber.mode & DebugTracingMode) {
- const name = getComponentNameFromFiber(fiber) || 'Unknown';
- logStateUpdateScheduled(name, lane, payload);
- }
- }
- }
-
if (enableSchedulingProfiler) {
markStateUpdateScheduled(fiber, lane);
}
@@ -269,15 +244,6 @@ const classComponentUpdater = {
entangleTransitions(root, fiber, lane);
}
- if (__DEV__) {
- if (enableDebugTracing) {
- if (fiber.mode & DebugTracingMode) {
- const name = getComponentNameFromFiber(fiber) || 'Unknown';
- logForceUpdateScheduled(name, lane);
- }
- }
- }
-
if (enableSchedulingProfiler) {
markForceUpdateScheduled(fiber, lane);
}
diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js
index 7887be44e46c0..df16eb96ef216 100644
--- a/packages/react-reconciler/src/ReactFiberCommitWork.js
+++ b/packages/react-reconciler/src/ReactFiberCommitWork.js
@@ -47,7 +47,6 @@ import {
enableSuspenseCallback,
enableScopeAPI,
enableUpdaterTracking,
- enableCache,
enableTransitionTracing,
enableUseEffectEventHook,
enableLegacyHidden,
@@ -2455,33 +2454,31 @@ function commitOffscreenPassiveMountEffects(
finishedWork: Fiber,
instance: OffscreenInstance,
) {
- if (enableCache) {
- let previousCache: Cache | null = null;
- if (
- current !== null &&
- current.memoizedState !== null &&
- current.memoizedState.cachePool !== null
- ) {
- previousCache = current.memoizedState.cachePool.pool;
- }
- let nextCache: Cache | null = null;
- if (
- finishedWork.memoizedState !== null &&
- finishedWork.memoizedState.cachePool !== null
- ) {
- nextCache = finishedWork.memoizedState.cachePool.pool;
+ let previousCache: Cache | null = null;
+ if (
+ current !== null &&
+ current.memoizedState !== null &&
+ current.memoizedState.cachePool !== null
+ ) {
+ previousCache = current.memoizedState.cachePool.pool;
+ }
+ let nextCache: Cache | null = null;
+ if (
+ finishedWork.memoizedState !== null &&
+ finishedWork.memoizedState.cachePool !== null
+ ) {
+ nextCache = finishedWork.memoizedState.cachePool.pool;
+ }
+ // Retain/release the cache used for pending (suspended) nodes.
+ // Note that this is only reached in the non-suspended/visible case:
+ // when the content is suspended/hidden, the retain/release occurs
+ // via the parent Suspense component (see case above).
+ if (nextCache !== previousCache) {
+ if (nextCache != null) {
+ retainCache(nextCache);
}
- // Retain/release the cache used for pending (suspended) nodes.
- // Note that this is only reached in the non-suspended/visible case:
- // when the content is suspended/hidden, the retain/release occurs
- // via the parent Suspense component (see case above).
- if (nextCache !== previousCache) {
- if (nextCache != null) {
- retainCache(nextCache);
- }
- if (previousCache != null) {
- releaseCache(previousCache);
- }
+ if (previousCache != null) {
+ releaseCache(previousCache);
}
}
@@ -2552,22 +2549,20 @@ function commitCachePassiveMountEffect(
current: Fiber | null,
finishedWork: Fiber,
) {
- if (enableCache) {
- let previousCache: Cache | null = null;
- if (finishedWork.alternate !== null) {
- previousCache = finishedWork.alternate.memoizedState.cache;
- }
- const nextCache = finishedWork.memoizedState.cache;
- // Retain/release the cache. In theory the cache component
- // could be "borrowing" a cache instance owned by some parent,
- // in which case we could avoid retaining/releasing. But it
- // is non-trivial to determine when that is the case, so we
- // always retain/release.
- if (nextCache !== previousCache) {
- retainCache(nextCache);
- if (previousCache != null) {
- releaseCache(previousCache);
- }
+ let previousCache: Cache | null = null;
+ if (finishedWork.alternate !== null) {
+ previousCache = finishedWork.alternate.memoizedState.cache;
+ }
+ const nextCache = finishedWork.memoizedState.cache;
+ // Retain/release the cache. In theory the cache component
+ // could be "borrowing" a cache instance owned by some parent,
+ // in which case we could avoid retaining/releasing. But it
+ // is non-trivial to determine when that is the case, so we
+ // always retain/release.
+ if (nextCache !== previousCache) {
+ retainCache(nextCache);
+ if (previousCache != null) {
+ releaseCache(previousCache);
}
}
}
@@ -2712,23 +2707,21 @@ function commitPassiveMountOnFiber(
endTime,
);
if (flags & Passive) {
- if (enableCache) {
- let previousCache: Cache | null = null;
- if (finishedWork.alternate !== null) {
- previousCache = finishedWork.alternate.memoizedState.cache;
- }
- const nextCache = finishedWork.memoizedState.cache;
- // Retain/release the root cache.
- // Note that on initial mount, previousCache and nextCache will be the same
- // and this retain won't occur. To counter this, we instead retain the HostRoot's
- // initial cache when creating the root itself (see createFiberRoot() in
- // ReactFiberRoot.js). Subsequent updates that change the cache are reflected
- // here, such that previous/next caches are retained correctly.
- if (nextCache !== previousCache) {
- retainCache(nextCache);
- if (previousCache != null) {
- releaseCache(previousCache);
- }
+ let previousCache: Cache | null = null;
+ if (finishedWork.alternate !== null) {
+ previousCache = finishedWork.alternate.memoizedState.cache;
+ }
+ const nextCache = finishedWork.memoizedState.cache;
+ // Retain/release the root cache.
+ // Note that on initial mount, previousCache and nextCache will be the same
+ // and this retain won't occur. To counter this, we instead retain the HostRoot's
+ // initial cache when creating the root itself (see createFiberRoot() in
+ // ReactFiberRoot.js). Subsequent updates that change the cache are reflected
+ // here, such that previous/next caches are retained correctly.
+ if (nextCache !== previousCache) {
+ retainCache(nextCache);
+ if (previousCache != null) {
+ releaseCache(previousCache);
}
}
@@ -2845,17 +2838,15 @@ function commitPassiveMountOnFiber(
if (disableLegacyMode || finishedWork.mode & ConcurrentMode) {
// The effects are currently disconnected. Since the tree is hidden,
// don't connect them. This also applies to the initial render.
- if (enableCache || enableTransitionTracing) {
- // "Atomic" effects are ones that need to fire on every commit,
- // even during pre-rendering. An example is updating the reference
- // count on cache instances.
- recursivelyTraverseAtomicPassiveEffects(
- finishedRoot,
- finishedWork,
- committedLanes,
- committedTransitions,
- );
- }
+ // "Atomic" effects are ones that need to fire on every commit,
+ // even during pre-rendering. An example is updating the reference
+ // count on cache instances.
+ recursivelyTraverseAtomicPassiveEffects(
+ finishedRoot,
+ finishedWork,
+ committedLanes,
+ committedTransitions,
+ );
} else {
// Legacy Mode: Fire the effects even if the tree is hidden.
instance._visibility |= OffscreenPassiveEffectsConnected;
@@ -3065,17 +3056,15 @@ export function reconnectPassiveEffects(
if (disableLegacyMode || finishedWork.mode & ConcurrentMode) {
// The effects are currently disconnected. Since the tree is hidden,
// don't connect them. This also applies to the initial render.
- if (enableCache || enableTransitionTracing) {
- // "Atomic" effects are ones that need to fire on every commit,
- // even during pre-rendering. An example is updating the reference
- // count on cache instances.
- recursivelyTraverseAtomicPassiveEffects(
- finishedRoot,
- finishedWork,
- committedLanes,
- committedTransitions,
- );
- }
+ // "Atomic" effects are ones that need to fire on every commit,
+ // even during pre-rendering. An example is updating the reference
+ // count on cache instances.
+ recursivelyTraverseAtomicPassiveEffects(
+ finishedRoot,
+ finishedWork,
+ committedLanes,
+ committedTransitions,
+ );
} else {
// Legacy Mode: Fire the effects even if the tree is hidden.
instance._visibility |= OffscreenPassiveEffectsConnected;
@@ -3618,27 +3607,23 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
// the cache instance owned by the root will never be freed.
// When effects are run, the cache should be freed here:
// case HostRoot: {
- // if (enableCache) {
- // const cache = current.memoizedState.cache;
- // releaseCache(cache);
- // }
+ // const cache = current.memoizedState.cache;
+ // releaseCache(cache);
// break;
// }
case LegacyHiddenComponent:
case OffscreenComponent: {
- if (enableCache) {
- if (
- current.memoizedState !== null &&
- current.memoizedState.cachePool !== null
- ) {
- const cache: Cache = current.memoizedState.cachePool.pool;
- // Retain/release the cache used for pending (suspended) nodes.
- // Note that this is only reached in the non-suspended/visible case:
- // when the content is suspended/hidden, the retain/release occurs
- // via the parent Suspense component (see case above).
- if (cache != null) {
- retainCache(cache);
- }
+ if (
+ current.memoizedState !== null &&
+ current.memoizedState.cachePool !== null
+ ) {
+ const cache: Cache = current.memoizedState.cachePool.pool;
+ // Retain/release the cache used for pending (suspended) nodes.
+ // Note that this is only reached in the non-suspended/visible case:
+ // when the content is suspended/hidden, the retain/release occurs
+ // via the parent Suspense component (see case above).
+ if (cache != null) {
+ retainCache(cache);
}
}
break;
@@ -3681,10 +3666,8 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
break;
}
case CacheComponent: {
- if (enableCache) {
- const cache = current.memoizedState.cache;
- releaseCache(cache);
- }
+ const cache = current.memoizedState.cache;
+ releaseCache(cache);
break;
}
case TracingMarkerComponent: {
diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.js b/packages/react-reconciler/src/ReactFiberCompleteWork.js
index b24351ac383b9..b302b498fa14d 100644
--- a/packages/react-reconciler/src/ReactFiberCompleteWork.js
+++ b/packages/react-reconciler/src/ReactFiberCompleteWork.js
@@ -37,7 +37,6 @@ import {
enableScopeAPI,
enablePersistedModeClonedFlag,
enableProfilerTimer,
- enableCache,
enableTransitionTracing,
enableRenderableContext,
passChildrenWhenCloningPersistedNodes,
@@ -985,18 +984,16 @@ function completeWork(
}
}
- if (enableCache) {
- let previousCache: Cache | null = null;
- if (current !== null) {
- previousCache = current.memoizedState.cache;
- }
- const cache: Cache = workInProgress.memoizedState.cache;
- if (cache !== previousCache) {
- // Run passive effects to retain/release the cache.
- workInProgress.flags |= Passive;
- }
- popCacheProvider(workInProgress, cache);
+ let previousCache: Cache | null = null;
+ if (current !== null) {
+ previousCache = current.memoizedState.cache;
+ }
+ const cache: Cache = workInProgress.memoizedState.cache;
+ if (cache !== previousCache) {
+ // Run passive effects to retain/release the cache.
+ workInProgress.flags |= Passive;
}
+ popCacheProvider(workInProgress, cache);
if (enableTransitionTracing) {
popRootMarkerInstance(workInProgress);
@@ -1384,7 +1381,7 @@ function completeWork(
current !== null &&
(current.memoizedState: null | SuspenseState) !== null;
- if (enableCache && nextDidTimeout) {
+ if (nextDidTimeout) {
const offscreenFiber: Fiber = (workInProgress.child: any);
let previousCache: Cache | null = null;
if (
@@ -1783,26 +1780,24 @@ function completeWork(
scheduleRetryEffect(workInProgress, retryQueue);
}
- if (enableCache) {
- let previousCache: Cache | null = null;
- if (
- current !== null &&
- current.memoizedState !== null &&
- current.memoizedState.cachePool !== null
- ) {
- previousCache = current.memoizedState.cachePool.pool;
- }
- let cache: Cache | null = null;
- if (
- workInProgress.memoizedState !== null &&
- workInProgress.memoizedState.cachePool !== null
- ) {
- cache = workInProgress.memoizedState.cachePool.pool;
- }
- if (cache !== previousCache) {
- // Run passive effects to retain/release the cache.
- workInProgress.flags |= Passive;
- }
+ let previousCache: Cache | null = null;
+ if (
+ current !== null &&
+ current.memoizedState !== null &&
+ current.memoizedState.cachePool !== null
+ ) {
+ previousCache = current.memoizedState.cachePool.pool;
+ }
+ let cache: Cache | null = null;
+ if (
+ workInProgress.memoizedState !== null &&
+ workInProgress.memoizedState.cachePool !== null
+ ) {
+ cache = workInProgress.memoizedState.cachePool.pool;
+ }
+ if (cache !== previousCache) {
+ // Run passive effects to retain/release the cache.
+ workInProgress.flags |= Passive;
}
popTransition(workInProgress, current);
@@ -1810,19 +1805,17 @@ function completeWork(
return null;
}
case CacheComponent: {
- if (enableCache) {
- let previousCache: Cache | null = null;
- if (current !== null) {
- previousCache = current.memoizedState.cache;
- }
- const cache: Cache = workInProgress.memoizedState.cache;
- if (cache !== previousCache) {
- // Run passive effects to retain/release the cache.
- workInProgress.flags |= Passive;
- }
- popCacheProvider(workInProgress, cache);
- bubbleProperties(workInProgress);
+ let previousCache: Cache | null = null;
+ if (current !== null) {
+ previousCache = current.memoizedState.cache;
}
+ const cache: Cache = workInProgress.memoizedState.cache;
+ if (cache !== previousCache) {
+ // Run passive effects to retain/release the cache.
+ workInProgress.flags |= Passive;
+ }
+ popCacheProvider(workInProgress, cache);
+ bubbleProperties(workInProgress);
return null;
}
case TracingMarkerComponent: {
diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js
index d2df61063f687..8affe4804b8ab 100644
--- a/packages/react-reconciler/src/ReactFiberHooks.js
+++ b/packages/react-reconciler/src/ReactFiberHooks.js
@@ -35,9 +35,7 @@ import {
} from './ReactFiberConfig';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import {
- enableDebugTracing,
enableSchedulingProfiler,
- enableCache,
enableLazyContextPropagation,
enableTransitionTracing,
enableUseEffectEventHook,
@@ -56,7 +54,6 @@ import {
import {
NoMode,
ConcurrentMode,
- DebugTracingMode,
StrictEffectsMode,
StrictLegacyMode,
NoStrictPassiveEffectsMode,
@@ -125,7 +122,6 @@ import {
getIsHydrating,
tryToClaimNextHydratableFormMarkerInstance,
} from './ReactFiberHydrationContext';
-import {logStateUpdateScheduled} from './DebugTracing';
import {
markStateUpdateScheduled,
setIsStrictModeForDevtools,
@@ -3594,9 +3590,6 @@ function updateRefresh(): any {
}
function refreshCache(fiber: Fiber, seedKey: ?() => T, seedValue: T): void {
- if (!enableCache) {
- return;
- }
// TODO: Does Cache work in legacy mode? Should decide and write a test.
// TODO: Consider warning if the refresh is at discrete priority, or if we
// otherwise suspect that it wasn't batched properly.
@@ -3928,15 +3921,6 @@ function entangleTransitionUpdate(
}
function markUpdateInDevTools(fiber: Fiber, lane: Lane, action: A): void {
- if (__DEV__) {
- if (enableDebugTracing) {
- if (fiber.mode & DebugTracingMode) {
- const name = getComponentNameFromFiber(fiber) || 'Unknown';
- logStateUpdateScheduled(name, lane, action);
- }
- }
- }
-
if (enableSchedulingProfiler) {
markStateUpdateScheduled(fiber, lane);
}
@@ -3966,10 +3950,8 @@ export const ContextOnlyDispatcher: Dispatcher = {
useActionState: throwInvalidHookError,
useOptimistic: throwInvalidHookError,
useMemoCache: throwInvalidHookError,
+ useCacheRefresh: throwInvalidHookError,
};
-if (enableCache) {
- (ContextOnlyDispatcher: Dispatcher).useCacheRefresh = throwInvalidHookError;
-}
if (enableUseEffectEventHook) {
(ContextOnlyDispatcher: Dispatcher).useEffectEvent = throwInvalidHookError;
}
@@ -4005,10 +3987,8 @@ const HooksDispatcherOnMount: Dispatcher = {
useActionState: mountActionState,
useOptimistic: mountOptimistic,
useMemoCache,
+ useCacheRefresh: mountRefresh,
};
-if (enableCache) {
- (HooksDispatcherOnMount: Dispatcher).useCacheRefresh = mountRefresh;
-}
if (enableUseEffectEventHook) {
(HooksDispatcherOnMount: Dispatcher).useEffectEvent = mountEvent;
}
@@ -4044,10 +4024,8 @@ const HooksDispatcherOnUpdate: Dispatcher = {
useActionState: updateActionState,
useOptimistic: updateOptimistic,
useMemoCache,
+ useCacheRefresh: updateRefresh,
};
-if (enableCache) {
- (HooksDispatcherOnUpdate: Dispatcher).useCacheRefresh = updateRefresh;
-}
if (enableUseEffectEventHook) {
(HooksDispatcherOnUpdate: Dispatcher).useEffectEvent = updateEvent;
}
@@ -4084,10 +4062,8 @@ const HooksDispatcherOnRerender: Dispatcher = {
useActionState: rerenderActionState,
useOptimistic: rerenderOptimistic,
useMemoCache,
+ useCacheRefresh: updateRefresh,
};
-if (enableCache) {
- (HooksDispatcherOnRerender: Dispatcher).useCacheRefresh = updateRefresh;
-}
if (enableUseEffectEventHook) {
(HooksDispatcherOnRerender: Dispatcher).useEffectEvent = updateEvent;
}
@@ -4283,15 +4259,12 @@ if (__DEV__) {
},
useHostTransitionStatus,
useMemoCache,
+ useCacheRefresh() {
+ currentHookNameInDev = 'useCacheRefresh';
+ mountHookTypesDev();
+ return mountRefresh();
+ },
};
- if (enableCache) {
- (HooksDispatcherOnMountInDEV: Dispatcher).useCacheRefresh =
- function useCacheRefresh() {
- currentHookNameInDev = 'useCacheRefresh';
- mountHookTypesDev();
- return mountRefresh();
- };
- }
if (enableUseEffectEventHook) {
(HooksDispatcherOnMountInDEV: Dispatcher).useEffectEvent =
function useEffectEvent) => Return>(
@@ -4485,15 +4458,12 @@ if (__DEV__) {
},
useHostTransitionStatus,
useMemoCache,
+ useCacheRefresh() {
+ currentHookNameInDev = 'useCacheRefresh';
+ updateHookTypesDev();
+ return mountRefresh();
+ },
};
- if (enableCache) {
- (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).useCacheRefresh =
- function useCacheRefresh() {
- currentHookNameInDev = 'useCacheRefresh';
- updateHookTypesDev();
- return mountRefresh();
- };
- }
if (enableUseEffectEventHook) {
(HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).useEffectEvent =
function useEffectEvent) => Return>(
@@ -4686,15 +4656,12 @@ if (__DEV__) {
},
useHostTransitionStatus,
useMemoCache,
+ useCacheRefresh() {
+ currentHookNameInDev = 'useCacheRefresh';
+ updateHookTypesDev();
+ return updateRefresh();
+ },
};
- if (enableCache) {
- (HooksDispatcherOnUpdateInDEV: Dispatcher).useCacheRefresh =
- function useCacheRefresh() {
- currentHookNameInDev = 'useCacheRefresh';
- updateHookTypesDev();
- return updateRefresh();
- };
- }
if (enableUseEffectEventHook) {
(HooksDispatcherOnUpdateInDEV: Dispatcher).useEffectEvent =
function useEffectEvent) => Return>(
@@ -4887,15 +4854,12 @@ if (__DEV__) {
},
useHostTransitionStatus,
useMemoCache,
+ useCacheRefresh() {
+ currentHookNameInDev = 'useCacheRefresh';
+ updateHookTypesDev();
+ return updateRefresh();
+ },
};
- if (enableCache) {
- (HooksDispatcherOnRerenderInDEV: Dispatcher).useCacheRefresh =
- function useCacheRefresh() {
- currentHookNameInDev = 'useCacheRefresh';
- updateHookTypesDev();
- return updateRefresh();
- };
- }
if (enableUseEffectEventHook) {
(HooksDispatcherOnRerenderInDEV: Dispatcher).useEffectEvent =
function useEffectEvent) => Return>(
@@ -5112,15 +5076,12 @@ if (__DEV__) {
return useMemoCache(size);
},
useHostTransitionStatus,
+ useCacheRefresh() {
+ currentHookNameInDev = 'useCacheRefresh';
+ mountHookTypesDev();
+ return mountRefresh();
+ },
};
- if (enableCache) {
- (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).useCacheRefresh =
- function useCacheRefresh() {
- currentHookNameInDev = 'useCacheRefresh';
- mountHookTypesDev();
- return mountRefresh();
- };
- }
if (enableUseEffectEventHook) {
(InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).useEffectEvent =
function useEffectEvent) => Return>(
@@ -5340,15 +5301,12 @@ if (__DEV__) {
return useMemoCache(size);
},
useHostTransitionStatus,
+ useCacheRefresh() {
+ currentHookNameInDev = 'useCacheRefresh';
+ updateHookTypesDev();
+ return updateRefresh();
+ },
};
- if (enableCache) {
- (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).useCacheRefresh =
- function useCacheRefresh() {
- currentHookNameInDev = 'useCacheRefresh';
- updateHookTypesDev();
- return updateRefresh();
- };
- }
if (enableUseEffectEventHook) {
(InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).useEffectEvent =
function useEffectEvent) => Return>(
@@ -5568,15 +5526,12 @@ if (__DEV__) {
return useMemoCache(size);
},
useHostTransitionStatus,
+ useCacheRefresh() {
+ currentHookNameInDev = 'useCacheRefresh';
+ updateHookTypesDev();
+ return updateRefresh();
+ },
};
- if (enableCache) {
- (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).useCacheRefresh =
- function useCacheRefresh() {
- currentHookNameInDev = 'useCacheRefresh';
- updateHookTypesDev();
- return updateRefresh();
- };
- }
if (enableUseEffectEventHook) {
(InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).useEffectEvent =
function useEffectEvent) => Return>(
diff --git a/packages/react-reconciler/src/ReactFiberRoot.js b/packages/react-reconciler/src/ReactFiberRoot.js
index 176c3846d1336..29bc7923d893e 100644
--- a/packages/react-reconciler/src/ReactFiberRoot.js
+++ b/packages/react-reconciler/src/ReactFiberRoot.js
@@ -28,7 +28,6 @@ import {
} from './ReactFiberLane';
import {
enableSuspenseCallback,
- enableCache,
enableProfilerCommitHooks,
enableProfilerTimer,
enableUpdaterTracking,
@@ -91,10 +90,8 @@ function FiberRootNode(
this.onCaughtError = onCaughtError;
this.onRecoverableError = onRecoverableError;
- if (enableCache) {
- this.pooledCache = null;
- this.pooledCacheLanes = NoLanes;
- }
+ this.pooledCache = null;
+ this.pooledCacheLanes = NoLanes;
if (enableSuspenseCallback) {
this.hydrationCallbacks = null;
@@ -196,33 +193,24 @@ export function createFiberRoot(
root.current = uninitializedFiber;
uninitializedFiber.stateNode = root;
- if (enableCache) {
- const initialCache = createCache();
- retainCache(initialCache);
-
- // The pooledCache is a fresh cache instance that is used temporarily
- // for newly mounted boundaries during a render. In general, the
- // pooledCache is always cleared from the root at the end of a render:
- // it is either released when render commits, or moved to an Offscreen
- // component if rendering suspends. Because the lifetime of the pooled
- // cache is distinct from the main memoizedState.cache, it must be
- // retained separately.
- root.pooledCache = initialCache;
- retainCache(initialCache);
- const initialState: RootState = {
- element: initialChildren,
- isDehydrated: hydrate,
- cache: initialCache,
- };
- uninitializedFiber.memoizedState = initialState;
- } else {
- const initialState: RootState = {
- element: initialChildren,
- isDehydrated: hydrate,
- cache: (null: any), // not enabled yet
- };
- uninitializedFiber.memoizedState = initialState;
- }
+ const initialCache = createCache();
+ retainCache(initialCache);
+
+ // The pooledCache is a fresh cache instance that is used temporarily
+ // for newly mounted boundaries during a render. In general, the
+ // pooledCache is always cleared from the root at the end of a render:
+ // it is either released when render commits, or moved to an Offscreen
+ // component if rendering suspends. Because the lifetime of the pooled
+ // cache is distinct from the main memoizedState.cache, it must be
+ // retained separately.
+ root.pooledCache = initialCache;
+ retainCache(initialCache);
+ const initialState: RootState = {
+ element: initialChildren,
+ isDehydrated: hydrate,
+ cache: initialCache,
+ };
+ uninitializedFiber.memoizedState = initialState;
initializeUpdateQueue(uninitializedFiber);
diff --git a/packages/react-reconciler/src/ReactFiberThrow.js b/packages/react-reconciler/src/ReactFiberThrow.js
index e901486c1d448..a4bdb84e6c4e7 100644
--- a/packages/react-reconciler/src/ReactFiberThrow.js
+++ b/packages/react-reconciler/src/ReactFiberThrow.js
@@ -37,9 +37,8 @@ import {
ForceClientRender,
ScheduleRetry,
} from './ReactFiberFlags';
-import {NoMode, ConcurrentMode, DebugTracingMode} from './ReactTypeOfMode';
+import {NoMode, ConcurrentMode} from './ReactTypeOfMode';
import {
- enableDebugTracing,
enableLazyContextPropagation,
enableUpdaterTracking,
enablePostpone,
@@ -70,7 +69,6 @@ import {
} from './ReactFiberWorkLoop';
import {propagateParentContextChangesToDeferredTree} from './ReactFiberNewContext';
import {logUncaughtError, logCaughtError} from './ReactFiberErrorLogger';
-import {logComponentSuspended} from './DebugTracing';
import {isDevToolsPresent} from './ReactFiberDevToolsHook';
import {
SyncLane,
@@ -399,15 +397,6 @@ function throwException(
}
}
- if (__DEV__) {
- if (enableDebugTracing) {
- if (sourceFiber.mode & DebugTracingMode) {
- const name = getComponentNameFromFiber(sourceFiber) || 'Unknown';
- logComponentSuspended(name, wakeable);
- }
- }
- }
-
// Mark the nearest Suspense boundary to switch to rendering a fallback.
const suspenseBoundary = getSuspenseHandler();
if (suspenseBoundary !== null) {
diff --git a/packages/react-reconciler/src/ReactFiberTransition.js b/packages/react-reconciler/src/ReactFiberTransition.js
index 8953ca1457271..db4db589084f1 100644
--- a/packages/react-reconciler/src/ReactFiberTransition.js
+++ b/packages/react-reconciler/src/ReactFiberTransition.js
@@ -16,7 +16,7 @@ import type {
Transition,
} from './ReactFiberTracingMarkerComponent';
-import {enableCache, enableTransitionTracing} from 'shared/ReactFeatureFlags';
+import {enableTransitionTracing} from 'shared/ReactFeatureFlags';
import {isPrimaryRenderer} from './ReactFiberConfig';
import {createCursor, push, pop} from './ReactFiberStack';
import {
@@ -98,10 +98,6 @@ const transitionStack: StackCursor | null> =
createCursor(null);
function peekCacheFromPool(): Cache | null {
- if (!enableCache) {
- return (null: any);
- }
-
// Check if the cache pool already has a cache we can use.
// If we're rendering inside a Suspense boundary that is currently hidden,
@@ -173,12 +169,10 @@ export function pushTransition(
prevCachePool: SpawnedCachePool | null,
newTransitions: Array | null,
): void {
- if (enableCache) {
- if (prevCachePool === null) {
- push(resumedCache, resumedCache.current, offscreenWorkInProgress);
- } else {
- push(resumedCache, prevCachePool.pool, offscreenWorkInProgress);
- }
+ if (prevCachePool === null) {
+ push(resumedCache, resumedCache.current, offscreenWorkInProgress);
+ } else {
+ push(resumedCache, prevCachePool.pool, offscreenWorkInProgress);
}
if (enableTransitionTracing) {
@@ -202,9 +196,7 @@ export function popTransition(workInProgress: Fiber, current: Fiber | null) {
pop(transitionStack, workInProgress);
}
- if (enableCache) {
- pop(resumedCache, workInProgress);
- }
+ pop(resumedCache, workInProgress);
}
}
@@ -217,9 +209,6 @@ export function getPendingTransitions(): Array | null {
}
export function getSuspendedCache(): SpawnedCachePool | null {
- if (!enableCache) {
- return null;
- }
// This function is called when a Suspense boundary suspends. It returns the
// cache that would have been used to render fresh data during this render,
// if there was any, so that we can resume rendering with the same cache when
@@ -240,10 +229,6 @@ export function getSuspendedCache(): SpawnedCachePool | null {
}
export function getOffscreenDeferredCache(): SpawnedCachePool | null {
- if (!enableCache) {
- return null;
- }
-
const cacheFromPool = peekCacheFromPool();
if (cacheFromPool === null) {
return null;
diff --git a/packages/react-reconciler/src/ReactFiberUnwindWork.js b/packages/react-reconciler/src/ReactFiberUnwindWork.js
index cc77647cb8556..cdc887b5af819 100644
--- a/packages/react-reconciler/src/ReactFiberUnwindWork.js
+++ b/packages/react-reconciler/src/ReactFiberUnwindWork.js
@@ -33,7 +33,6 @@ import {DidCapture, NoFlags, ShouldCapture} from './ReactFiberFlags';
import {NoMode, ProfileMode} from './ReactTypeOfMode';
import {
enableProfilerTimer,
- enableCache,
enableTransitionTracing,
enableRenderableContext,
} from 'shared/ReactFeatureFlags';
@@ -91,10 +90,8 @@ function unwindWork(
}
case HostRoot: {
const root: FiberRoot = workInProgress.stateNode;
- if (enableCache) {
- const cache: Cache = workInProgress.memoizedState.cache;
- popCacheProvider(workInProgress, cache);
- }
+ const cache: Cache = workInProgress.memoizedState.cache;
+ popCacheProvider(workInProgress, cache);
if (enableTransitionTracing) {
popRootMarkerInstance(workInProgress);
@@ -189,10 +186,8 @@ function unwindWork(
return null;
}
case CacheComponent:
- if (enableCache) {
- const cache: Cache = workInProgress.memoizedState.cache;
- popCacheProvider(workInProgress, cache);
- }
+ const cache: Cache = workInProgress.memoizedState.cache;
+ popCacheProvider(workInProgress, cache);
return null;
case TracingMarkerComponent:
if (enableTransitionTracing) {
@@ -226,10 +221,8 @@ function unwindInterruptedWork(
}
case HostRoot: {
const root: FiberRoot = interruptedWork.stateNode;
- if (enableCache) {
- const cache: Cache = interruptedWork.memoizedState.cache;
- popCacheProvider(interruptedWork, cache);
- }
+ const cache: Cache = interruptedWork.memoizedState.cache;
+ popCacheProvider(interruptedWork, cache);
if (enableTransitionTracing) {
popRootMarkerInstance(interruptedWork);
@@ -271,10 +264,8 @@ function unwindInterruptedWork(
popTransition(interruptedWork, current);
break;
case CacheComponent:
- if (enableCache) {
- const cache: Cache = interruptedWork.memoizedState.cache;
- popCacheProvider(interruptedWork, cache);
- }
+ const cache: Cache = interruptedWork.memoizedState.cache;
+ popCacheProvider(interruptedWork, cache);
break;
case TracingMarkerComponent:
if (enableTransitionTracing) {
diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js
index dd637d687da4f..9a002ce4b6fd9 100644
--- a/packages/react-reconciler/src/ReactFiberWorkLoop.js
+++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js
@@ -29,10 +29,8 @@ import {
enableProfilerTimer,
enableProfilerCommitHooks,
enableProfilerNestedUpdatePhase,
- enableDebugTracing,
enableSchedulingProfiler,
enableUpdaterTracking,
- enableCache,
enableTransitionTracing,
useModernStrictMode,
disableLegacyContext,
@@ -55,16 +53,6 @@ import {
NormalPriority as NormalSchedulerPriority,
IdlePriority as IdleSchedulerPriority,
} from './Scheduler';
-import {
- logCommitStarted,
- logCommitStopped,
- logLayoutEffectsStarted,
- logLayoutEffectsStopped,
- logPassiveEffectsStarted,
- logPassiveEffectsStopped,
- logRenderStarted,
- logRenderStopped,
-} from './DebugTracing';
import {
logBlockingStart,
logTransitionStart,
@@ -2124,19 +2112,13 @@ function popDispatcher(prevDispatcher: any) {
}
function pushAsyncDispatcher() {
- if (enableCache || __DEV__) {
- const prevAsyncDispatcher = ReactSharedInternals.A;
- ReactSharedInternals.A = DefaultAsyncDispatcher;
- return prevAsyncDispatcher;
- } else {
- return null;
- }
+ const prevAsyncDispatcher = ReactSharedInternals.A;
+ ReactSharedInternals.A = DefaultAsyncDispatcher;
+ return prevAsyncDispatcher;
}
function popAsyncDispatcher(prevAsyncDispatcher: any) {
- if (enableCache || __DEV__) {
- ReactSharedInternals.A = prevAsyncDispatcher;
- }
+ ReactSharedInternals.A = prevAsyncDispatcher;
}
export function markCommitTimeOfFallback() {
@@ -2260,12 +2242,6 @@ function renderRootSync(
prepareFreshStack(root, lanes);
}
- if (__DEV__) {
- if (enableDebugTracing) {
- logRenderStarted(lanes);
- }
- }
-
if (enableSchedulingProfiler) {
markRenderStarted(lanes);
}
@@ -2360,12 +2336,6 @@ function renderRootSync(
popDispatcher(prevDispatcher);
popAsyncDispatcher(prevAsyncDispatcher);
- if (__DEV__) {
- if (enableDebugTracing) {
- logRenderStopped();
- }
- }
-
if (enableSchedulingProfiler) {
markRenderStopped();
}
@@ -2433,12 +2403,6 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
workInProgressRootIsPrerendering = checkIfRootIsPrerendering(root, lanes);
}
- if (__DEV__) {
- if (enableDebugTracing) {
- logRenderStarted(lanes);
- }
- }
-
if (enableSchedulingProfiler) {
markRenderStarted(lanes);
}
@@ -2651,12 +2615,6 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
popAsyncDispatcher(prevAsyncDispatcher);
executionContext = prevExecutionContext;
- if (__DEV__) {
- if (enableDebugTracing) {
- logRenderStopped();
- }
- }
-
// Check if the tree has completed.
if (workInProgress !== null) {
// Still work remaining.
@@ -3223,27 +3181,14 @@ function commitRootImpl(
}
}
- if (__DEV__) {
- if (enableDebugTracing) {
- logCommitStarted(lanes);
- }
- }
-
if (enableSchedulingProfiler) {
markCommitStarted(lanes);
}
if (finishedWork === null) {
- if (__DEV__) {
- if (enableDebugTracing) {
- logCommitStopped();
- }
- }
-
if (enableSchedulingProfiler) {
markCommitStopped();
}
-
return null;
} else {
if (__DEV__) {
@@ -3409,21 +3354,10 @@ function commitRootImpl(
// The next phase is the layout phase, where we call effects that read
// the host tree after it's been mutated. The idiomatic use case for this is
// layout, but class component lifecycles also fire here for legacy reasons.
- if (__DEV__) {
- if (enableDebugTracing) {
- logLayoutEffectsStarted(lanes);
- }
- }
if (enableSchedulingProfiler) {
markLayoutEffectsStarted(lanes);
}
commitLayoutEffects(finishedWork, root, lanes);
- if (__DEV__) {
- if (enableDebugTracing) {
- logLayoutEffectsStopped();
- }
- }
-
if (enableSchedulingProfiler) {
markLayoutEffectsStopped();
}
@@ -3589,12 +3523,6 @@ function commitRootImpl(
// If layout work was scheduled, flush it now.
flushSyncWorkOnAllRoots();
- if (__DEV__) {
- if (enableDebugTracing) {
- logCommitStopped();
- }
- }
-
if (enableSchedulingProfiler) {
markCommitStopped();
}
@@ -3652,16 +3580,14 @@ function makeErrorInfo(componentStack: ?string) {
}
function releaseRootPooledCache(root: FiberRoot, remainingLanes: Lanes) {
- if (enableCache) {
- const pooledCacheLanes = (root.pooledCacheLanes &= remainingLanes);
- if (pooledCacheLanes === NoLanes) {
- // None of the remaining work relies on the cache pool. Clear it so
- // subsequent requests get a new cache
- const pooledCache = root.pooledCache;
- if (pooledCache != null) {
- root.pooledCache = null;
- releaseCache(pooledCache);
- }
+ const pooledCacheLanes = (root.pooledCacheLanes &= remainingLanes);
+ if (pooledCacheLanes === NoLanes) {
+ // None of the remaining work relies on the cache pool. Clear it so
+ // subsequent requests get a new cache
+ const pooledCache = root.pooledCache;
+ if (pooledCache != null) {
+ root.pooledCache = null;
+ releaseCache(pooledCache);
}
}
}
@@ -3735,10 +3661,6 @@ function flushPassiveEffectsImpl(wasDelayedCommit: void | boolean) {
if (__DEV__) {
isFlushingPassiveEffects = true;
didScheduleUpdateDuringPassiveEffects = false;
-
- if (enableDebugTracing) {
- logPassiveEffectsStarted(lanes);
- }
}
let passiveEffectStartTime = 0;
@@ -3767,12 +3689,6 @@ function flushPassiveEffectsImpl(wasDelayedCommit: void | boolean) {
pendingPassiveEffectsRenderEndTime,
);
- if (__DEV__) {
- if (enableDebugTracing) {
- logPassiveEffectsStopped();
- }
- }
-
if (enableSchedulingProfiler) {
markPassiveEffectsStopped();
}
diff --git a/packages/react-reconciler/src/ReactTypeOfMode.js b/packages/react-reconciler/src/ReactTypeOfMode.js
index 7542c8eff528c..fd67d9979f8bb 100644
--- a/packages/react-reconciler/src/ReactTypeOfMode.js
+++ b/packages/react-reconciler/src/ReactTypeOfMode.js
@@ -12,8 +12,8 @@ export type TypeOfMode = number;
export const NoMode = /* */ 0b0000000;
// TODO: Remove ConcurrentMode by reading from the root tag instead
export const ConcurrentMode = /* */ 0b0000001;
-export const ProfileMode = /* */ 0b0000010;
-export const DebugTracingMode = /* */ 0b0000100;
+export const ProfileMode = /* */ 0b0000010;
+//export const DebugTracingMode = /* */ 0b0000100; // Removed
export const StrictLegacyMode = /* */ 0b0001000;
export const StrictEffectsMode = /* */ 0b0010000;
export const NoStrictPassiveEffectsMode = /* */ 0b1000000;
diff --git a/packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js b/packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js
deleted file mode 100644
index ba0451c4c5f0b..0000000000000
--- a/packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js
+++ /dev/null
@@ -1,440 +0,0 @@
-/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @emails react-core
- */
-
-'use strict';
-
-describe('DebugTracing', () => {
- let React;
- let ReactNoop;
- let waitForPaint;
- let waitForAll;
- let act;
-
- let logs;
-
- const SYNC_LANE_STRING = '0b0000000000000000000000000000010';
- const DEFAULT_LANE_STRING = '0b0000000000000000000000000100000';
- const RETRY_LANE_STRING = '0b0000000010000000000000000000000';
-
- global.IS_REACT_ACT_ENVIRONMENT = true;
-
- beforeEach(() => {
- jest.resetModules();
-
- React = require('react');
- ReactNoop = require('react-noop-renderer');
- const InternalTestUtils = require('internal-test-utils');
- waitForPaint = InternalTestUtils.waitForPaint;
- waitForAll = InternalTestUtils.waitForAll;
- act = InternalTestUtils.act;
-
- logs = [];
-
- const groups = [];
-
- spyOnDevAndProd(console, 'log').mockImplementation(message => {
- logs.push(`log: ${message.replace(/%c/g, '')}`);
- });
- spyOnDevAndProd(console, 'group').mockImplementation(message => {
- logs.push(`group: ${message.replace(/%c/g, '')}`);
- groups.push(message);
- });
- spyOnDevAndProd(console, 'groupEnd').mockImplementation(() => {
- const message = groups.pop();
- logs.push(`groupEnd: ${message.replace(/%c/g, '')}`);
- });
- });
-
- // @gate enableDebugTracing
- it('should not log anything for sync render without suspends or state updates', async () => {
- await act(() => {
- ReactNoop.render(
-
-
- ,
- );
- });
-
- expect(logs).toEqual([]);
- });
-
- // @gate experimental && enableDebugTracing
- it('should not log anything for concurrent render without suspends or state updates', async () => {
- await act(() =>
- ReactNoop.render(
-
-
- ,
- ),
- );
- expect(logs).toEqual([]);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing && !disableLegacyMode
- it('should log sync render with suspense, legacy', async () => {
- let resolveFakeSuspensePromise;
- let didResolve = false;
- const fakeSuspensePromise = new Promise(resolve => {
- resolveFakeSuspensePromise = () => {
- didResolve = true;
- resolve();
- };
- });
-
- function Example() {
- if (!didResolve) {
- throw fakeSuspensePromise;
- }
- return null;
- }
-
- ReactNoop.renderLegacySyncRoot(
-
-
-
-
- ,
- );
-
- expect(logs).toEqual([
- `group: ⚛ render (${SYNC_LANE_STRING})`,
- 'log: ⚛ Example suspended',
- `groupEnd: ⚛ render (${SYNC_LANE_STRING})`,
- ]);
-
- logs.splice(0);
-
- resolveFakeSuspensePromise();
- await waitForAll([]);
-
- expect(logs).toEqual(['log: ⚛ Example resolved']);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing && enableCPUSuspense && !disableLegacyMode
- it('should log sync render with CPU suspense, legacy', async () => {
- function Example() {
- console.log('');
- return null;
- }
-
- function Wrapper({children}) {
- console.log('');
- return children;
- }
-
- ReactNoop.renderLegacySyncRoot(
-
-
-
-
-
-
- ,
- );
-
- expect(logs).toEqual([
- `group: ⚛ render (${SYNC_LANE_STRING})`,
- 'log: ',
- `groupEnd: ⚛ render (${SYNC_LANE_STRING})`,
- ]);
-
- logs.splice(0);
-
- await waitForPaint([]);
-
- expect(logs).toEqual([
- `group: ⚛ render (${RETRY_LANE_STRING})`,
- 'log: ',
- `groupEnd: ⚛ render (${RETRY_LANE_STRING})`,
- ]);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing
- it('should log concurrent render with suspense', async () => {
- let isResolved = false;
- let resolveFakeSuspensePromise;
- const fakeSuspensePromise = new Promise(resolve => {
- resolveFakeSuspensePromise = () => {
- resolve();
- isResolved = true;
- };
- });
-
- function Example() {
- if (!isResolved) {
- throw fakeSuspensePromise;
- }
- return null;
- }
-
- await act(() =>
- ReactNoop.render(
-
-
-
-
- ,
- ),
- );
-
- expect(logs).toEqual([
- `group: ⚛ render (${DEFAULT_LANE_STRING})`,
- 'log: ⚛ Example suspended',
- `groupEnd: ⚛ render (${DEFAULT_LANE_STRING})`,
-
- ...(gate('enableSiblingPrerendering')
- ? [
- `group: ⚛ render (${RETRY_LANE_STRING})`,
- 'log: ⚛ Example suspended',
- `groupEnd: ⚛ render (${RETRY_LANE_STRING})`,
- ]
- : []),
- ]);
-
- logs.splice(0);
-
- await act(async () => await resolveFakeSuspensePromise());
- expect(logs).toEqual([
- 'log: ⚛ Example resolved',
-
- ...(gate('enableSiblingPrerendering')
- ? ['log: ⚛ Example resolved']
- : []),
- ]);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing && enableCPUSuspense
- it('should log concurrent render with CPU suspense', async () => {
- function Example() {
- console.log('');
- return null;
- }
-
- function Wrapper({children}) {
- console.log('');
- return children;
- }
-
- await act(() =>
- ReactNoop.render(
-
-
-
-
-
-
- ,
- ),
- );
-
- expect(logs).toEqual([
- `group: ⚛ render (${DEFAULT_LANE_STRING})`,
- 'log: ',
- `groupEnd: ⚛ render (${DEFAULT_LANE_STRING})`,
- `group: ⚛ render (${RETRY_LANE_STRING})`,
- 'log: ',
- `groupEnd: ⚛ render (${RETRY_LANE_STRING})`,
- ]);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing
- it('should log cascading class component updates', async () => {
- class Example extends React.Component {
- state = {didMount: false};
- componentDidMount() {
- this.setState({didMount: true});
- }
- render() {
- return null;
- }
- }
-
- await act(() =>
- ReactNoop.render(
-
-
- ,
- ),
- );
-
- expect(logs).toEqual([
- `group: ⚛ commit (${DEFAULT_LANE_STRING})`,
- `group: ⚛ layout effects (${DEFAULT_LANE_STRING})`,
- `log: ⚛ Example updated state (${SYNC_LANE_STRING})`,
- `groupEnd: ⚛ layout effects (${DEFAULT_LANE_STRING})`,
- `groupEnd: ⚛ commit (${DEFAULT_LANE_STRING})`,
- ]);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing
- it('should log render phase state updates for class component', async () => {
- class Example extends React.Component {
- state = {didRender: false};
- render() {
- if (this.state.didRender === false) {
- this.setState({didRender: true});
- }
- return null;
- }
- }
-
- await expect(async () => {
- await act(() => {
- ReactNoop.render(
-
-
- ,
- );
- });
- }).toErrorDev(
- 'Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.',
- );
-
- expect(logs).toEqual([
- `group: ⚛ render (${DEFAULT_LANE_STRING})`,
- `log: ⚛ Example updated state (${DEFAULT_LANE_STRING})`,
- `groupEnd: ⚛ render (${DEFAULT_LANE_STRING})`,
- ]);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing
- it('should log cascading layout updates', async () => {
- function Example() {
- const [didMount, setDidMount] = React.useState(false);
- React.useLayoutEffect(() => {
- setDidMount(true);
- }, []);
- return didMount;
- }
-
- await act(() =>
- ReactNoop.render(
-
-
- ,
- ),
- );
-
- expect(logs).toEqual([
- `group: ⚛ commit (${DEFAULT_LANE_STRING})`,
- `group: ⚛ layout effects (${DEFAULT_LANE_STRING})`,
- `log: ⚛ Example updated state (${SYNC_LANE_STRING})`,
- `groupEnd: ⚛ layout effects (${DEFAULT_LANE_STRING})`,
- `groupEnd: ⚛ commit (${DEFAULT_LANE_STRING})`,
- ]);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing
- it('should log cascading passive updates', async () => {
- function Example() {
- const [didMount, setDidMount] = React.useState(false);
- React.useEffect(() => {
- setDidMount(true);
- }, []);
- return didMount;
- }
-
- await act(() => {
- ReactNoop.render(
-
-
- ,
- );
- });
- expect(logs).toEqual([
- `group: ⚛ passive effects (${DEFAULT_LANE_STRING})`,
- `log: ⚛ Example updated state (${DEFAULT_LANE_STRING})`,
- `groupEnd: ⚛ passive effects (${DEFAULT_LANE_STRING})`,
- ]);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing
- it('should log render phase updates', async () => {
- function Example() {
- const [didRender, setDidRender] = React.useState(false);
- if (!didRender) {
- setDidRender(true);
- }
- return didRender;
- }
-
- await act(() => {
- ReactNoop.render(
-
-
- ,
- );
- });
-
- expect(logs).toEqual([
- `group: ⚛ render (${DEFAULT_LANE_STRING})`,
- `log: ⚛ Example updated state (${DEFAULT_LANE_STRING})`,
- `groupEnd: ⚛ render (${DEFAULT_LANE_STRING})`,
- ]);
- });
-
- // @gate experimental && build === 'development' && enableDebugTracing
- it('should log when user code logs', async () => {
- function Example() {
- console.log('Hello from user code');
- return null;
- }
-
- await act(() =>
- ReactNoop.render(
-
-
- ,
- ),
- );
-
- expect(logs).toEqual([
- `group: ⚛ render (${DEFAULT_LANE_STRING})`,
- 'log: Hello from user code',
- `groupEnd: ⚛ render (${DEFAULT_LANE_STRING})`,
- ]);
- });
-
- // @gate experimental && enableDebugTracing
- it('should not log anything outside of a unstable_DebugTracingMode subtree', async () => {
- function ExampleThatCascades() {
- const [didMount, setDidMount] = React.useState(false);
- React.useLayoutEffect(() => {
- setDidMount(true);
- }, []);
- return didMount;
- }
-
- const fakeSuspensePromise = {then() {}};
-
- function ExampleThatSuspends() {
- throw fakeSuspensePromise;
- }
-
- function Example() {
- return null;
- }
-
- await act(() =>
- ReactNoop.render(
-
-
-
-
-
-
-
-
- ,
- ),
- );
-
- expect(logs).toEqual([]);
- });
-});
diff --git a/packages/react-reconciler/src/__tests__/ReactCache-test.js b/packages/react-reconciler/src/__tests__/ReactCache-test.js
index 7fd43b0b3611e..e93b68cec3d91 100644
--- a/packages/react-reconciler/src/__tests__/ReactCache-test.js
+++ b/packages/react-reconciler/src/__tests__/ReactCache-test.js
@@ -30,7 +30,6 @@ describe('ReactCache', () => {
__unmockReact();
});
- // @gate enableCache
it('cache objects and primitive arguments and a mix of them', async () => {
const types = cache((a, b) => ({a: typeof a, b: typeof b}));
function Print({a, b}) {
@@ -170,7 +169,6 @@ describe('ReactCache', () => {
).toEqual('number number true false false false ');
});
- // @gate enableCache
it('cached functions that throw should cache the error', async () => {
const throws = cache(v => {
throw new Error(v);
@@ -203,7 +201,6 @@ describe('ReactCache', () => {
expect(z).not.toBe(x);
});
- // @gate enableCache
it('introspection of returned wrapper function is same on client and server', async () => {
// When the variant flag is true, test the client version of `cache`.
if (gate(flags => flags.variant)) {
diff --git a/packages/react-server/src/ReactFizzHooks.js b/packages/react-server/src/ReactFizzHooks.js
index a163aa11516b7..83f51c6fb248e 100644
--- a/packages/react-server/src/ReactFizzHooks.js
+++ b/packages/react-server/src/ReactFizzHooks.js
@@ -39,7 +39,6 @@ import {
import {createFastHash} from './ReactServerStreamConfig';
import {
- enableCache,
enableUseEffectEventHook,
enableUseResourceEffectHook,
} from 'shared/ReactFeatureFlags';
@@ -859,11 +858,9 @@ export const HooksDispatcher: Dispatcher = supportsClientAPIs
useFormState: useActionState,
useHostTransitionStatus,
useMemoCache,
+ useCacheRefresh,
};
-if (enableCache) {
- HooksDispatcher.useCacheRefresh = useCacheRefresh;
-}
if (enableUseEffectEventHook) {
HooksDispatcher.useEffectEvent = useEffectEvent;
}
diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js
index ad6721ec60796..e0ff9593bc395 100644
--- a/packages/react-server/src/ReactFizzServer.js
+++ b/packages/react-server/src/ReactFizzServer.js
@@ -134,7 +134,6 @@ import {
REACT_LAZY_TYPE,
REACT_SUSPENSE_TYPE,
REACT_LEGACY_HIDDEN_TYPE,
- REACT_DEBUG_TRACING_MODE_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_PROFILER_TYPE,
REACT_SUSPENSE_LIST_TYPE,
@@ -153,7 +152,6 @@ import {
disableLegacyContext,
disableLegacyContextForFunctionComponents,
enableScopeAPI,
- enableCache,
enablePostpone,
enableHalt,
enableRenderableContext,
@@ -2136,7 +2134,6 @@ function renderElement(
// www build. As a migration step, we could add a special prop to Offscreen
// that simulates the old behavior (no hiding, no change to effects).
case REACT_LEGACY_HIDDEN_TYPE:
- case REACT_DEBUG_TRACING_MODE_TYPE:
case REACT_STRICT_MODE_TYPE:
case REACT_PROFILER_TYPE:
case REACT_FRAGMENT_TYPE: {
@@ -4418,11 +4415,8 @@ export function performWork(request: Request): void {
const prevContext = getActiveContext();
const prevDispatcher = ReactSharedInternals.H;
ReactSharedInternals.H = HooksDispatcher;
- let prevAsyncDispatcher = null;
- if (enableCache || __DEV__) {
- prevAsyncDispatcher = ReactSharedInternals.A;
- ReactSharedInternals.A = DefaultAsyncDispatcher;
- }
+ const prevAsyncDispatcher = ReactSharedInternals.A;
+ ReactSharedInternals.A = DefaultAsyncDispatcher;
const prevRequest = currentRequest;
currentRequest = request;
@@ -4452,9 +4446,7 @@ export function performWork(request: Request): void {
} finally {
setCurrentResumableState(prevResumableState);
ReactSharedInternals.H = prevDispatcher;
- if (enableCache) {
- ReactSharedInternals.A = prevAsyncDispatcher;
- }
+ ReactSharedInternals.A = prevAsyncDispatcher;
if (__DEV__) {
ReactSharedInternals.getCurrentStack = prevGetCurrentStackImpl;
diff --git a/packages/react/index.development.js b/packages/react/index.development.js
index 8472789ba36cd..809e940f070ba 100644
--- a/packages/react/index.development.js
+++ b/packages/react/index.development.js
@@ -45,7 +45,6 @@ export {
memo,
cache,
startTransition,
- unstable_DebugTracingMode,
unstable_LegacyHidden,
unstable_Activity,
unstable_Scope,
diff --git a/packages/react/index.experimental.development.js b/packages/react/index.experimental.development.js
index d41774e1feedc..cc753cd9c5ed8 100644
--- a/packages/react/index.experimental.development.js
+++ b/packages/react/index.experimental.development.js
@@ -28,7 +28,6 @@ export {
memo,
cache,
startTransition,
- unstable_DebugTracingMode,
unstable_Activity,
unstable_postpone,
unstable_getCacheForType,
diff --git a/packages/react/index.experimental.js b/packages/react/index.experimental.js
index ae98e3b91f19c..ab97c58caa5d2 100644
--- a/packages/react/index.experimental.js
+++ b/packages/react/index.experimental.js
@@ -28,7 +28,6 @@ export {
memo,
cache,
startTransition,
- unstable_DebugTracingMode,
unstable_Activity,
unstable_postpone,
unstable_getCacheForType,
diff --git a/packages/react/index.fb.js b/packages/react/index.fb.js
index 4764281481dbb..8cded91b9854d 100644
--- a/packages/react/index.fb.js
+++ b/packages/react/index.fb.js
@@ -33,7 +33,6 @@ export {
StrictMode,
Suspense,
unstable_Activity,
- unstable_DebugTracingMode,
unstable_getCacheForType,
unstable_LegacyHidden,
unstable_Scope,
diff --git a/packages/react/index.js b/packages/react/index.js
index 2edb0a2c1de09..3e087509ccb06 100644
--- a/packages/react/index.js
+++ b/packages/react/index.js
@@ -46,7 +46,6 @@ export {
memo,
cache,
startTransition,
- unstable_DebugTracingMode,
unstable_LegacyHidden,
unstable_Activity,
unstable_Scope,
diff --git a/packages/react/src/ReactClient.js b/packages/react/src/ReactClient.js
index 478d9e026aae8..90ce18b133a34 100644
--- a/packages/react/src/ReactClient.js
+++ b/packages/react/src/ReactClient.js
@@ -10,7 +10,6 @@
import ReactVersion from 'shared/ReactVersion';
import {
REACT_FRAGMENT_TYPE,
- REACT_DEBUG_TRACING_MODE_TYPE,
REACT_PROFILER_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_SUSPENSE_TYPE,
@@ -105,7 +104,6 @@ export {
REACT_FRAGMENT_TYPE as Fragment,
REACT_PROFILER_TYPE as Profiler,
REACT_STRICT_MODE_TYPE as StrictMode,
- REACT_DEBUG_TRACING_MODE_TYPE as unstable_DebugTracingMode,
REACT_SUSPENSE_TYPE as Suspense,
createElement,
cloneElement,
diff --git a/packages/react/src/ReactServer.experimental.development.js b/packages/react/src/ReactServer.experimental.development.js
index ccf423d79ecc7..82aff0d615fb4 100644
--- a/packages/react/src/ReactServer.experimental.development.js
+++ b/packages/react/src/ReactServer.experimental.development.js
@@ -15,7 +15,6 @@ import {
REACT_PROFILER_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_SUSPENSE_TYPE,
- REACT_DEBUG_TRACING_MODE_TYPE,
} from 'shared/ReactSymbols';
import {
cloneElement,
@@ -71,7 +70,6 @@ export {
memo,
cache,
startTransition,
- REACT_DEBUG_TRACING_MODE_TYPE as unstable_DebugTracingMode,
REACT_SUSPENSE_TYPE as unstable_SuspenseList,
getCacheForType as unstable_getCacheForType,
postpone as unstable_postpone,
diff --git a/packages/react/src/ReactServer.experimental.js b/packages/react/src/ReactServer.experimental.js
index 97b548f82d6b6..e77e249930e21 100644
--- a/packages/react/src/ReactServer.experimental.js
+++ b/packages/react/src/ReactServer.experimental.js
@@ -15,7 +15,6 @@ import {
REACT_PROFILER_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_SUSPENSE_TYPE,
- REACT_DEBUG_TRACING_MODE_TYPE,
} from 'shared/ReactSymbols';
import {
cloneElement,
@@ -70,7 +69,6 @@ export {
memo,
cache,
startTransition,
- REACT_DEBUG_TRACING_MODE_TYPE as unstable_DebugTracingMode,
REACT_SUSPENSE_TYPE as unstable_SuspenseList,
getCacheForType as unstable_getCacheForType,
postpone as unstable_postpone,
diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js
index afac564cad28a..d1dc6cb7f7907 100644
--- a/packages/shared/ReactFeatureFlags.js
+++ b/packages/shared/ReactFeatureFlags.js
@@ -77,7 +77,6 @@ export const enableLegacyFBSupport = false;
// likely to include in an upcoming release.
// -----------------------------------------------------------------------------
-export const enableCache = true;
export const enableLegacyCache = __EXPERIMENTAL__;
export const enableAsyncIterableChildren = __EXPERIMENTAL__;
@@ -267,11 +266,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
// Phase param passed to onRender callback differentiates between an "update" and a "cascading-update".
export const enableProfilerNestedUpdatePhase = __PROFILE__;
-// Adds verbose console logging for e.g. state updates, suspense, and work loop
-// stuff. Intended to enable React core members to more easily debug scheduling
-// issues in DEV builds.
-export const enableDebugTracing = false;
-
export const enableAsyncDebugInfo = __EXPERIMENTAL__;
// Track which Fiber(s) schedule render work.
diff --git a/packages/shared/ReactSymbols.js b/packages/shared/ReactSymbols.js
index 002870896f00f..0d1208b21af0c 100644
--- a/packages/shared/ReactSymbols.js
+++ b/packages/shared/ReactSymbols.js
@@ -33,9 +33,6 @@ export const REACT_SUSPENSE_LIST_TYPE: symbol = Symbol.for(
export const REACT_MEMO_TYPE: symbol = Symbol.for('react.memo');
export const REACT_LAZY_TYPE: symbol = Symbol.for('react.lazy');
export const REACT_SCOPE_TYPE: symbol = Symbol.for('react.scope');
-export const REACT_DEBUG_TRACING_MODE_TYPE: symbol = Symbol.for(
- 'react.debug_trace_mode',
-);
export const REACT_OFFSCREEN_TYPE: symbol = Symbol.for('react.offscreen');
export const REACT_LEGACY_HIDDEN_TYPE: symbol = Symbol.for(
'react.legacy_hidden',
diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js
index 4d89fa091061a..498af214b0188 100644
--- a/packages/shared/forks/ReactFeatureFlags.native-fb.js
+++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js
@@ -44,10 +44,8 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const disableTextareaChildren = false;
export const enableAsyncDebugInfo = false;
export const enableAsyncIterableChildren = false;
-export const enableCache = true;
export const enableCPUSuspense = true;
export const enableCreateEventHandleAPI = false;
-export const enableDebugTracing = false;
export const enableDeferRootSchedulingToMicrotask = true;
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
export const enableMoveBefore = true;
diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js
index 0407f01910b75..fb996a43adb6c 100644
--- a/packages/shared/forks/ReactFeatureFlags.native-oss.js
+++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js
@@ -31,10 +31,8 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const disableTextareaChildren = false;
export const enableAsyncDebugInfo = false;
export const enableAsyncIterableChildren = false;
-export const enableCache = true;
export const enableCPUSuspense = false;
export const enableCreateEventHandleAPI = false;
-export const enableDebugTracing = false;
export const enableDeferRootSchedulingToMicrotask = true;
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
export const enableFabricCompleteRootInCommitPhase = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js
index b83cb9a99fc3d..6646a126a0ceb 100644
--- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js
+++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js
@@ -11,7 +11,6 @@ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as ExportsType from './ReactFeatureFlags.test-renderer';
export const debugRenderPhaseSideEffectsForStrictMode = false;
-export const enableDebugTracing = false;
export const enableAsyncDebugInfo = false;
export const enableSchedulingProfiler = false;
export const enableProfilerTimer = __PROFILE__;
@@ -19,7 +18,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
export const enableProfilerNestedUpdatePhase = __PROFILE__;
export const enableComponentPerformanceTrack = false;
export const enableUpdaterTracking = false;
-export const enableCache = true;
export const enableLegacyCache = __EXPERIMENTAL__;
export const enableAsyncIterableChildren = false;
export const enableTaint = true;
diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
index 115117685aeb4..8f71306c51a62 100644
--- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
+++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
@@ -23,10 +23,8 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const disableTextareaChildren = false;
export const enableAsyncDebugInfo = false;
export const enableAsyncIterableChildren = false;
-export const enableCache = true;
export const enableCPUSuspense = true;
export const enableCreateEventHandleAPI = false;
-export const enableDebugTracing = false;
export const enableDeferRootSchedulingToMicrotask = true;
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
export const enableMoveBefore = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
index cad15eecc8c11..dae38936f8a01 100644
--- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
@@ -11,7 +11,6 @@ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as ExportsType from './ReactFeatureFlags.test-renderer.www';
export const debugRenderPhaseSideEffectsForStrictMode = false;
-export const enableDebugTracing = false;
export const enableAsyncDebugInfo = false;
export const enableSchedulingProfiler = false;
export const enableProfilerTimer = __PROFILE__;
@@ -19,7 +18,6 @@ export const enableProfilerCommitHooks = __PROFILE__;
export const enableProfilerNestedUpdatePhase = __PROFILE__;
export const enableComponentPerformanceTrack = false;
export const enableUpdaterTracking = false;
-export const enableCache = true;
export const enableLegacyCache = true;
export const enableAsyncIterableChildren = false;
export const enableTaint = true;
diff --git a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js
index 7c28c76fb1392..69da420d0422c 100644
--- a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js
+++ b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js
@@ -32,12 +32,6 @@ export const retryLaneExpirationMs = 5000;
export const syncLaneExpirationMs = 250;
export const transitionLaneExpirationMs = 5000;
-// Enable this flag to help with concurrent mode debugging.
-// It logs information to the console about React scheduling, rendering, and commit phases.
-//
-// NOTE: This feature will only work in DEV mode; all callsites are wrapped with __DEV__.
-export const enableDebugTracing = __EXPERIMENTAL__;
-
export const enableSchedulingProfiler = __VARIANT__;
export const enableInfiniteRenderLoopDetection = __VARIANT__;
diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js
index eea2ba4230f50..060600286e6de 100644
--- a/packages/shared/forks/ReactFeatureFlags.www.js
+++ b/packages/shared/forks/ReactFeatureFlags.www.js
@@ -19,7 +19,6 @@ export const {
disableDefaultPropsExceptForClasses,
disableLegacyContextForFunctionComponents,
disableSchedulerTimeoutInWorkLoop,
- enableDebugTracing,
enableDeferRootSchedulingToMicrotask,
enableDO_NOT_USE_disableStrictPassiveEffect,
enableHiddenSubtreeInsertionEffectCleanup,
@@ -70,7 +69,6 @@ export const enableSchedulingProfiler: boolean =
export const disableLegacyContext = __EXPERIMENTAL__;
export const enableGetInspectorDataForInstanceInProduction = false;
-export const enableCache = true;
export const enableLegacyCache = true;
export const enableAsyncIterableChildren = false;
diff --git a/packages/shared/isValidElementType.js b/packages/shared/isValidElementType.js
index 6d5397be33e70..346992b118865 100644
--- a/packages/shared/isValidElementType.js
+++ b/packages/shared/isValidElementType.js
@@ -14,7 +14,6 @@ import {
REACT_FORWARD_REF_TYPE,
REACT_FRAGMENT_TYPE,
REACT_PROFILER_TYPE,
- REACT_DEBUG_TRACING_MODE_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_SUSPENSE_TYPE,
REACT_SUSPENSE_LIST_TYPE,
@@ -28,7 +27,6 @@ import {
import {
enableScopeAPI,
enableTransitionTracing,
- enableDebugTracing,
enableLegacyHidden,
enableRenderableContext,
} from './ReactFeatureFlags';
@@ -46,7 +44,6 @@ export default function isValidElementType(type: mixed): boolean {
if (
type === REACT_FRAGMENT_TYPE ||
type === REACT_PROFILER_TYPE ||
- (enableDebugTracing && type === REACT_DEBUG_TRACING_MODE_TYPE) ||
type === REACT_STRICT_MODE_TYPE ||
type === REACT_SUSPENSE_TYPE ||
type === REACT_SUSPENSE_LIST_TYPE ||