Skip to content

Commit 57799b9

Browse files
authored
Add more feature flag checks (#24037)
1 parent e09518e commit 57799b9

5 files changed

Lines changed: 30 additions & 16 deletions

File tree

‎packages/react-reconciler/src/ReactFiber.new.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
enableSyncDefaultUpdates,
2727
allowConcurrentByDefault,
2828
enableTransitionTracing,
29+
enableDebugTracing,
2930
}from'shared/ReactFeatureFlags';
3031
import{
3132
supportsPersistence,
@@ -492,10 +493,6 @@ export function createFiberFromTypeAndProps(
492493
getTag: switch(type){
493494
caseREACT_FRAGMENT_TYPE:
494495
returncreateFiberFromFragment(pendingProps.children,mode,lanes,key);
495-
caseREACT_DEBUG_TRACING_MODE_TYPE:
496-
fiberTag=Mode;
497-
mode|=DebugTracingMode;
498-
break;
499496
caseREACT_STRICT_MODE_TYPE:
500497
fiberTag=Mode;
501498
mode|=StrictLegacyMode;
@@ -529,6 +526,13 @@ export function createFiberFromTypeAndProps(
529526
returncreateFiberFromTracingMarker(pendingProps,mode,lanes,key);
530527
}
531528
// eslint-disable-next-line no-fallthrough
529+
caseREACT_DEBUG_TRACING_MODE_TYPE:
530+
if(enableDebugTracing){
531+
fiberTag=Mode;
532+
mode|=DebugTracingMode;
533+
break;
534+
}
535+
// eslint-disable-next-line no-fallthrough
532536
default: {
533537
if(typeoftype==='object'&&type!==null){
534538
switch(type.$$typeof){

‎packages/react-reconciler/src/ReactFiber.old.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
enableSyncDefaultUpdates,
2727
allowConcurrentByDefault,
2828
enableTransitionTracing,
29+
enableDebugTracing,
2930
}from'shared/ReactFeatureFlags';
3031
import{
3132
supportsPersistence,
@@ -492,10 +493,6 @@ export function createFiberFromTypeAndProps(
492493
getTag: switch(type){
493494
caseREACT_FRAGMENT_TYPE:
494495
returncreateFiberFromFragment(pendingProps.children,mode,lanes,key);
495-
caseREACT_DEBUG_TRACING_MODE_TYPE:
496-
fiberTag=Mode;
497-
mode|=DebugTracingMode;
498-
break;
499496
caseREACT_STRICT_MODE_TYPE:
500497
fiberTag=Mode;
501498
mode|=StrictLegacyMode;
@@ -529,6 +526,13 @@ export function createFiberFromTypeAndProps(
529526
returncreateFiberFromTracingMarker(pendingProps,mode,lanes,key);
530527
}
531528
// eslint-disable-next-line no-fallthrough
529+
caseREACT_DEBUG_TRACING_MODE_TYPE:
530+
if(enableDebugTracing){
531+
fiberTag=Mode;
532+
mode|=DebugTracingMode;
533+
break;
534+
}
535+
// eslint-disable-next-line no-fallthrough
532536
default: {
533537
if(typeoftype==='object'&&type!==null){
534538
switch(type.$$typeof){

‎packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('DebugTracing', () => {
4545
});
4646
});
4747

48-
// @gateexperimental || www
48+
// @gateenableDebugTracing
4949
it('should not log anything for sync render without suspends or state updates',()=>{
5050
ReactTestRenderer.create(
5151
<React.unstable_DebugTracingMode>
@@ -56,8 +56,7 @@ describe('DebugTracing', () => {
5656
expect(logs).toEqual([]);
5757
});
5858

59-
// @gate build === 'development'
60-
// @gate experimental || www
59+
// @gate experimental && build === 'development' && enableDebugTracing
6160
it('should not log anything for concurrent render without suspends or state updates',()=>{
6261
ReactTestRenderer.act(()=>
6362
ReactTestRenderer.create(
@@ -376,8 +375,7 @@ describe('DebugTracing', () => {
376375
]);
377376
});
378377

379-
// @gate build === 'development'
380-
// @gate experimental || www
378+
// @gate experimental && build === 'development' && enableDebugTracing
381379
it('should not log anything outside of a unstable_DebugTracingMode subtree',()=>{
382380
functionExampleThatCascades(){
383381
const[didMount,setDidMount]=React.useState(false);

‎packages/shared/getComponentNameFromType.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {
2626
REACT_TRACING_MARKER_TYPE,
2727
}from'shared/ReactSymbols';
2828

29+
import{enableTransitionTracing,enableCache}from'./ReactFeatureFlags';
30+
2931
// Keep in sync with react-reconciler/getComponentNameFromFiber
3032
functiongetWrappedName(
3133
outerType: mixed,
@@ -79,9 +81,14 @@ export default function getComponentNameFromType(type: mixed): string | null {
7981
caseREACT_SUSPENSE_LIST_TYPE:
8082
return'SuspenseList';
8183
caseREACT_CACHE_TYPE:
82-
return'Cache';
84+
if(enableCache){
85+
return'Cache';
86+
}
87+
// eslint-disable-next-line no-fallthrough
8388
caseREACT_TRACING_MARKER_TYPE:
84-
return'TracingMarker';
89+
if(enableTransitionTracing){
90+
return'TracingMarker';
91+
}
8592
}
8693
if(typeoftype==='object'){
8794
switch(type.$$typeof){

‎packages/shared/isValidElementType.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
enableScopeAPI,
3030
enableCache,
3131
enableTransitionTracing,
32+
enableDebugTracing,
3233
}from'./ReactFeatureFlags';
3334

3435
constREACT_MODULE_REFERENCE: Symbol=Symbol.for('react.module.reference');
@@ -42,7 +43,7 @@ export default function isValidElementType(type: mixed) {
4243
if(
4344
type===REACT_FRAGMENT_TYPE||
4445
type===REACT_PROFILER_TYPE||
45-
type===REACT_DEBUG_TRACING_MODE_TYPE||
46+
(enableDebugTracing&&type===REACT_DEBUG_TRACING_MODE_TYPE)||
4647
type===REACT_STRICT_MODE_TYPE||
4748
type===REACT_SUSPENSE_TYPE||
4849
type===REACT_SUSPENSE_LIST_TYPE||

0 commit comments

Comments
 (0)