diff --git a/packages/react-reconciler/src/ReactFiber.new.js b/packages/react-reconciler/src/ReactFiber.new.js index ae51649b4a908..977a3f67e03d2 100644 --- a/packages/react-reconciler/src/ReactFiber.new.js +++ b/packages/react-reconciler/src/ReactFiber.new.js @@ -26,6 +26,7 @@ import { enableSyncDefaultUpdates, allowConcurrentByDefault, enableTransitionTracing, + enableDebugTracing, } from 'shared/ReactFeatureFlags'; import { supportsPersistence, @@ -492,10 +493,6 @@ export function createFiberFromTypeAndProps( getTag: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment(pendingProps.children, mode, lanes, key); - case REACT_DEBUG_TRACING_MODE_TYPE: - fiberTag = Mode; - mode |= DebugTracingMode; - break; case REACT_STRICT_MODE_TYPE: fiberTag = Mode; mode |= StrictLegacyMode; @@ -529,6 +526,13 @@ export function createFiberFromTypeAndProps( return createFiberFromTracingMarker(pendingProps, mode, lanes, key); } // eslint-disable-next-line no-fallthrough + case REACT_DEBUG_TRACING_MODE_TYPE: + if (enableDebugTracing) { + fiberTag = Mode; + mode |= DebugTracingMode; + break; + } + // eslint-disable-next-line no-fallthrough default: { if (typeof type === 'object' && type !== null) { switch (type.$$typeof) { diff --git a/packages/react-reconciler/src/ReactFiber.old.js b/packages/react-reconciler/src/ReactFiber.old.js index e590c3f493fbd..8999226fc22ef 100644 --- a/packages/react-reconciler/src/ReactFiber.old.js +++ b/packages/react-reconciler/src/ReactFiber.old.js @@ -26,6 +26,7 @@ import { enableSyncDefaultUpdates, allowConcurrentByDefault, enableTransitionTracing, + enableDebugTracing, } from 'shared/ReactFeatureFlags'; import { supportsPersistence, @@ -492,10 +493,6 @@ export function createFiberFromTypeAndProps( getTag: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment(pendingProps.children, mode, lanes, key); - case REACT_DEBUG_TRACING_MODE_TYPE: - fiberTag = Mode; - mode |= DebugTracingMode; - break; case REACT_STRICT_MODE_TYPE: fiberTag = Mode; mode |= StrictLegacyMode; @@ -529,6 +526,13 @@ export function createFiberFromTypeAndProps( return createFiberFromTracingMarker(pendingProps, mode, lanes, key); } // eslint-disable-next-line no-fallthrough + case REACT_DEBUG_TRACING_MODE_TYPE: + if (enableDebugTracing) { + fiberTag = Mode; + mode |= DebugTracingMode; + break; + } + // eslint-disable-next-line no-fallthrough default: { if (typeof type === 'object' && type !== null) { switch (type.$$typeof) { diff --git a/packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js b/packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js index 8be5b0bb9720e..f600ccb9c75e6 100644 --- a/packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js +++ b/packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js @@ -45,7 +45,7 @@ describe('DebugTracing', () => { }); }); - // @gate experimental || www + // @gate enableDebugTracing it('should not log anything for sync render without suspends or state updates', () => { ReactTestRenderer.create( @@ -56,8 +56,7 @@ describe('DebugTracing', () => { expect(logs).toEqual([]); }); - // @gate build === 'development' - // @gate experimental || www + // @gate experimental && build === 'development' && enableDebugTracing it('should not log anything for concurrent render without suspends or state updates', () => { ReactTestRenderer.act(() => ReactTestRenderer.create( @@ -376,8 +375,7 @@ describe('DebugTracing', () => { ]); }); - // @gate build === 'development' - // @gate experimental || www + // @gate experimental && build === 'development' && enableDebugTracing it('should not log anything outside of a unstable_DebugTracingMode subtree', () => { function ExampleThatCascades() { const [didMount, setDidMount] = React.useState(false); diff --git a/packages/shared/getComponentNameFromType.js b/packages/shared/getComponentNameFromType.js index 36432e56acada..7a732d915c210 100644 --- a/packages/shared/getComponentNameFromType.js +++ b/packages/shared/getComponentNameFromType.js @@ -26,6 +26,8 @@ import { REACT_TRACING_MARKER_TYPE, } from 'shared/ReactSymbols'; +import {enableTransitionTracing, enableCache} from './ReactFeatureFlags'; + // Keep in sync with react-reconciler/getComponentNameFromFiber function getWrappedName( outerType: mixed, @@ -79,9 +81,14 @@ export default function getComponentNameFromType(type: mixed): string | null { case REACT_SUSPENSE_LIST_TYPE: return 'SuspenseList'; case REACT_CACHE_TYPE: - return 'Cache'; + if (enableCache) { + return 'Cache'; + } + // eslint-disable-next-line no-fallthrough case REACT_TRACING_MARKER_TYPE: - return 'TracingMarker'; + if (enableTransitionTracing) { + return 'TracingMarker'; + } } if (typeof type === 'object') { switch (type.$$typeof) { diff --git a/packages/shared/isValidElementType.js b/packages/shared/isValidElementType.js index 295a39bf4321f..d3e4666e79dee 100644 --- a/packages/shared/isValidElementType.js +++ b/packages/shared/isValidElementType.js @@ -29,6 +29,7 @@ import { enableScopeAPI, enableCache, enableTransitionTracing, + enableDebugTracing, } from './ReactFeatureFlags'; const REACT_MODULE_REFERENCE: Symbol = Symbol.for('react.module.reference'); @@ -42,7 +43,7 @@ export default function isValidElementType(type: mixed) { if ( type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || - type === REACT_DEBUG_TRACING_MODE_TYPE || + (enableDebugTracing && type === REACT_DEBUG_TRACING_MODE_TYPE) || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE ||