@samitouri / QOS-React / commits / 57799b912d

Add more feature flag checks (#24037)

Sebastian Markbåge committed Mar 7, 2022 at 21:13 UTC 57799b912d365b373d2fe18d637e77480415df91
5 files changed +30 -16
packages/react-reconciler/src/ReactFiber.new.js
+8 -4
@@ -26,6 +26,7 @@ import {
26 enableSyncDefaultUpdates,
27 allowConcurrentByDefault,
28 enableTransitionTracing,
29 + enableDebugTracing,
30 } from 'shared/ReactFeatureFlags';
31 import {
32 supportsPersistence,
@@ -492,10 +493,6 @@ export function createFiberFromTypeAndProps(
493 getTag: switch (type) {
494 case REACT_FRAGMENT_TYPE:
495 return createFiberFromFragment(pendingProps.children, mode, lanes, key);
495 - case REACT_DEBUG_TRACING_MODE_TYPE:
496 - fiberTag = Mode;
497 - mode |= DebugTracingMode;
498 - break;
496 case REACT_STRICT_MODE_TYPE:
497 fiberTag = Mode;
498 mode |= StrictLegacyMode;
@@ -529,6 +526,13 @@ export function createFiberFromTypeAndProps(
526 return createFiberFromTracingMarker(pendingProps, mode, lanes, key);
527 }
528 // eslint-disable-next-line no-fallthrough
529 + case REACT_DEBUG_TRACING_MODE_TYPE:
530 + if (enableDebugTracing) {
531 + fiberTag = Mode;
532 + mode |= DebugTracingMode;
533 + break;
534 + }
535 + // eslint-disable-next-line no-fallthrough
536 default: {
537 if (typeof type === 'object' && type !== null) {
538 switch (type.$$typeof) {
packages/react-reconciler/src/ReactFiber.old.js
+8 -4
@@ -26,6 +26,7 @@ import {
26 enableSyncDefaultUpdates,
27 allowConcurrentByDefault,
28 enableTransitionTracing,
29 + enableDebugTracing,
30 } from 'shared/ReactFeatureFlags';
31 import {
32 supportsPersistence,
@@ -492,10 +493,6 @@ export function createFiberFromTypeAndProps(
493 getTag: switch (type) {
494 case REACT_FRAGMENT_TYPE:
495 return createFiberFromFragment(pendingProps.children, mode, lanes, key);
495 - case REACT_DEBUG_TRACING_MODE_TYPE:
496 - fiberTag = Mode;
497 - mode |= DebugTracingMode;
498 - break;
496 case REACT_STRICT_MODE_TYPE:
497 fiberTag = Mode;
498 mode |= StrictLegacyMode;
@@ -529,6 +526,13 @@ export function createFiberFromTypeAndProps(
526 return createFiberFromTracingMarker(pendingProps, mode, lanes, key);
527 }
528 // eslint-disable-next-line no-fallthrough
529 + case REACT_DEBUG_TRACING_MODE_TYPE:
530 + if (enableDebugTracing) {
531 + fiberTag = Mode;
532 + mode |= DebugTracingMode;
533 + break;
534 + }
535 + // eslint-disable-next-line no-fallthrough
536 default: {
537 if (typeof type === 'object' && type !== null) {
538 switch (type.$$typeof) {
packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js
+3 -5
@@ -45,7 +45,7 @@ describe('DebugTracing', () => {
45 });
46 });
47
48 - // @gate experimental || www
48 + // @gate enableDebugTracing
49 it('should not log anything for sync render without suspends or state updates', () => {
50 ReactTestRenderer.create(
51 <React.unstable_DebugTracingMode>
@@ -56,8 +56,7 @@ describe('DebugTracing', () => {
56 expect(logs).toEqual([]);
57 });
58
59 - // @gate build === 'development'
60 - // @gate experimental || www
59 + // @gate experimental && build === 'development' && enableDebugTracing
60 it('should not log anything for concurrent render without suspends or state updates', () => {
61 ReactTestRenderer.act(() =>
62 ReactTestRenderer.create(
@@ -376,8 +375,7 @@ describe('DebugTracing', () => {
375 ]);
376 });
377
379 - // @gate build === 'development'
380 - // @gate experimental || www
378 + // @gate experimental && build === 'development' && enableDebugTracing
379 it('should not log anything outside of a unstable_DebugTracingMode subtree', () => {
380 function ExampleThatCascades() {
381 const [didMount, setDidMount] = React.useState(false);
packages/shared/getComponentNameFromType.js
+9 -2
@@ -26,6 +26,8 @@ import {
26 REACT_TRACING_MARKER_TYPE,
27 } from 'shared/ReactSymbols';
28
29 +import {enableTransitionTracing, enableCache} from './ReactFeatureFlags';
30 +
31 // Keep in sync with react-reconciler/getComponentNameFromFiber
32 function getWrappedName(
33 outerType: mixed,
@@ -79,9 +81,14 @@ export default function getComponentNameFromType(type: mixed): string | null {
81 case REACT_SUSPENSE_LIST_TYPE:
82 return 'SuspenseList';
83 case REACT_CACHE_TYPE:
82 - return 'Cache';
84 + if (enableCache) {
85 + return 'Cache';
86 + }
87 + // eslint-disable-next-line no-fallthrough
88 case REACT_TRACING_MARKER_TYPE:
84 - return 'TracingMarker';
89 + if (enableTransitionTracing) {
90 + return 'TracingMarker';
91 + }
92 }
93 if (typeof type === 'object') {
94 switch (type.$$typeof) {
packages/shared/isValidElementType.js
+2 -1
@@ -29,6 +29,7 @@ import {
29 enableScopeAPI,
30 enableCache,
31 enableTransitionTracing,
32 + enableDebugTracing,
33 } from './ReactFeatureFlags';
34
35 const REACT_MODULE_REFERENCE: Symbol = Symbol.for('react.module.reference');
@@ -42,7 +43,7 @@ export default function isValidElementType(type: mixed) {
43 if (
44 type === REACT_FRAGMENT_TYPE ||
45 type === REACT_PROFILER_TYPE ||
45 - type === REACT_DEBUG_TRACING_MODE_TYPE ||
46 + (enableDebugTracing && type === REACT_DEBUG_TRACING_MODE_TYPE) ||
47 type === REACT_STRICT_MODE_TYPE ||
48 type === REACT_SUSPENSE_TYPE ||
49 type === REACT_SUSPENSE_LIST_TYPE ||