Skip to content

Commit 6da9a91

Browse files
committed
Revert "Add unstable context bailout for profiling (facebook#30407)"
This reverts commit 1350a85.
1 parent 693d471 commit 6da9a91

16 files changed

+52
-508
lines changed

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
150150

151151
let currentFiber: null | Fiber = null;
152152
let currentHook: null | Hook = null;
153-
let currentContextDependency:
154-
| null
155-
| ContextDependency<mixed>
156-
| ContextDependencyWithSelect<mixed> = null;
153+
let currentContextDependency: null | ContextDependency<mixed> = null;
157154

158155
function nextHook(): null | Hook {
159156
const hook = currentHook;

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ import {
4343
debugRenderPhaseSideEffectsForStrictMode,
4444
disableLegacyMode,
4545
enableNoCloningMemoCache,
46-
enableContextProfiling,
47-
enableUseResourceEffectHook,
4846
} from 'shared/ReactFeatureFlags';
4947
import {
5048
REACT_CONTEXT_TYPE,
@@ -78,11 +76,7 @@ import {
7876
ContinuousEventPriority,
7977
higherEventPriority,
8078
} from './ReactEventPriorities';
81-
import {
82-
readContext,
83-
readContextAndCompare,
84-
checkIfContextChanged,
85-
} from './ReactFiberNewContext';
79+
import {readContext, checkIfContextChanged} from './ReactFiberNewContext';
8680
import {HostRoot, CacheComponent, HostComponent} from './ReactWorkTags';
8781
import {
8882
LayoutStatic as LayoutStaticEffect,
@@ -3958,10 +3952,6 @@ if (enableUseEffectEventHook) {
39583952
if (enableUseResourceEffectHook) {
39593953
(ContextOnlyDispatcher: Dispatcher).useResourceEffect = throwInvalidHookError;
39603954
}
3961-
if (enableContextProfiling) {
3962-
(ContextOnlyDispatcher: Dispatcher).unstable_useContextWithBailout =
3963-
throwInvalidHookError;
3964-
}
39653955

39663956
const HooksDispatcherOnMount: Dispatcher = {
39673957
readContext,
@@ -3995,10 +3985,6 @@ if (enableUseEffectEventHook) {
39953985
if (enableUseResourceEffectHook) {
39963986
(HooksDispatcherOnMount: Dispatcher).useResourceEffect = mountResourceEffect;
39973987
}
3998-
if (enableContextProfiling) {
3999-
(HooksDispatcherOnMount: Dispatcher).unstable_useContextWithBailout =
4000-
unstable_useContextWithBailout;
4001-
}
40023988

40033989
const HooksDispatcherOnUpdate: Dispatcher = {
40043990
readContext,
@@ -4033,10 +4019,6 @@ if (enableUseResourceEffectHook) {
40334019
(HooksDispatcherOnUpdate: Dispatcher).useResourceEffect =
40344020
updateResourceEffect;
40354021
}
4036-
if (enableContextProfiling) {
4037-
(HooksDispatcherOnUpdate: Dispatcher).unstable_useContextWithBailout =
4038-
unstable_useContextWithBailout;
4039-
}
40404022

40414023
const HooksDispatcherOnRerender: Dispatcher = {
40424024
readContext,
@@ -4071,10 +4053,6 @@ if (enableUseResourceEffectHook) {
40714053
(HooksDispatcherOnRerender: Dispatcher).useResourceEffect =
40724054
updateResourceEffect;
40734055
}
4074-
if (enableContextProfiling) {
4075-
(HooksDispatcherOnRerender: Dispatcher).unstable_useContextWithBailout =
4076-
unstable_useContextWithBailout;
4077-
}
40784056

40794057
let HooksDispatcherOnMountInDEV: Dispatcher | null = null;
40804058
let HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher | null = null;
@@ -4296,17 +4274,6 @@ if (__DEV__) {
42964274
);
42974275
};
42984276
}
4299-
if (enableContextProfiling) {
4300-
(HooksDispatcherOnMountInDEV: Dispatcher).unstable_useContextWithBailout =
4301-
function <T>(
4302-
context: ReactContext<T>,
4303-
select: (T => Array<mixed>) | null,
4304-
): T {
4305-
currentHookNameInDev = 'useContext';
4306-
mountHookTypesDev();
4307-
return unstable_useContextWithBailout(context, select);
4308-
};
4309-
}
43104277

43114278
HooksDispatcherOnMountWithHookTypesInDEV = {
43124279
readContext<T>(context: ReactContext<T>): T {
@@ -4494,17 +4461,6 @@ if (__DEV__) {
44944461
);
44954462
};
44964463
}
4497-
if (enableContextProfiling) {
4498-
(HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).unstable_useContextWithBailout =
4499-
function <T>(
4500-
context: ReactContext<T>,
4501-
select: (T => Array<mixed>) | null,
4502-
): T {
4503-
currentHookNameInDev = 'useContext';
4504-
updateHookTypesDev();
4505-
return unstable_useContextWithBailout(context, select);
4506-
};
4507-
}
45084464

45094465
HooksDispatcherOnUpdateInDEV = {
45104466
readContext<T>(context: ReactContext<T>): T {
@@ -4692,17 +4648,6 @@ if (__DEV__) {
46924648
);
46934649
};
46944650
}
4695-
if (enableContextProfiling) {
4696-
(HooksDispatcherOnUpdateInDEV: Dispatcher).unstable_useContextWithBailout =
4697-
function <T>(
4698-
context: ReactContext<T>,
4699-
select: (T => Array<mixed>) | null,
4700-
): T {
4701-
currentHookNameInDev = 'useContext';
4702-
updateHookTypesDev();
4703-
return unstable_useContextWithBailout(context, select);
4704-
};
4705-
}
47064651

47074652
HooksDispatcherOnRerenderInDEV = {
47084653
readContext<T>(context: ReactContext<T>): T {
@@ -4890,17 +4835,6 @@ if (__DEV__) {
48904835
);
48914836
};
48924837
}
4893-
if (enableContextProfiling) {
4894-
(HooksDispatcherOnUpdateInDEV: Dispatcher).unstable_useContextWithBailout =
4895-
function <T>(
4896-
context: ReactContext<T>,
4897-
select: (T => Array<mixed>) | null,
4898-
): T {
4899-
currentHookNameInDev = 'useContext';
4900-
updateHookTypesDev();
4901-
return unstable_useContextWithBailout(context, select);
4902-
};
4903-
}
49044838

49054839
InvalidNestedHooksDispatcherOnMountInDEV = {
49064840
readContext<T>(context: ReactContext<T>): T {
@@ -5114,18 +5048,6 @@ if (__DEV__) {
51145048
);
51155049
};
51165050
}
5117-
if (enableContextProfiling) {
5118-
(HooksDispatcherOnUpdateInDEV: Dispatcher).unstable_useContextWithBailout =
5119-
function <T>(
5120-
context: ReactContext<T>,
5121-
select: (T => Array<mixed>) | null,
5122-
): T {
5123-
currentHookNameInDev = 'useContext';
5124-
warnInvalidHookAccess();
5125-
mountHookTypesDev();
5126-
return unstable_useContextWithBailout(context, select);
5127-
};
5128-
}
51295051

51305052
InvalidNestedHooksDispatcherOnUpdateInDEV = {
51315053
readContext<T>(context: ReactContext<T>): T {
@@ -5339,18 +5261,6 @@ if (__DEV__) {
53395261
);
53405262
};
53415263
}
5342-
if (enableContextProfiling) {
5343-
(InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).unstable_useContextWithBailout =
5344-
function <T>(
5345-
context: ReactContext<T>,
5346-
select: (T => Array<mixed>) | null,
5347-
): T {
5348-
currentHookNameInDev = 'useContext';
5349-
warnInvalidHookAccess();
5350-
updateHookTypesDev();
5351-
return unstable_useContextWithBailout(context, select);
5352-
};
5353-
}
53545264

53555265
InvalidNestedHooksDispatcherOnRerenderInDEV = {
53565266
readContext<T>(context: ReactContext<T>): T {
@@ -5564,16 +5474,4 @@ if (__DEV__) {
55645474
);
55655475
};
55665476
}
5567-
if (enableContextProfiling) {
5568-
(InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).unstable_useContextWithBailout =
5569-
function <T>(
5570-
context: ReactContext<T>,
5571-
select: (T => Array<mixed>) | null,
5572-
): T {
5573-
currentHookNameInDev = 'useContext';
5574-
warnInvalidHookAccess();
5575-
updateHookTypesDev();
5576-
return unstable_useContextWithBailout(context, select);
5577-
};
5578-
}
55795477
}

0 commit comments

Comments
 (0)