Skip to content

Commit 26f85a4

Browse files
committed
Remove Suspense priority warning
1 parent 812277d commit 26f85a4

File tree

2 files changed

+2
-129
lines changed

2 files changed

+2
-129
lines changed

packages/react-reconciler/src/ReactFiberThrow.js

-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import {
5454
markLegacyErrorBoundaryAsFailed,
5555
isAlreadyFailedLegacyErrorBoundary,
5656
pingSuspendedRoot,
57-
checkForWrongSuspensePriorityInDEV,
5857
} from './ReactFiberWorkLoop';
5958

6059
import {Sync} from './ReactFiberExpirationTime';
@@ -207,8 +206,6 @@ function throwException(
207206
}
208207
}
209208

210-
checkForWrongSuspensePriorityInDEV(sourceFiber);
211-
212209
let hasInvisibleParentBoundary = hasSuspenseContext(
213210
suspenseStackCursor.current,
214211
(InvisibleParentSuspenseContext: SuspenseContext),

packages/react-reconciler/src/ReactFiberWorkLoop.js

+2-126
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,6 @@ function finishConcurrentRender(
779779
if (expirationTime === lastSuspendedTime) {
780780
root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
781781
}
782-
flushSuspensePriorityWarningInDEV();
783782

784783
// We have an acceptable loading state. We need to figure out if we
785784
// should immediately commit it or wait a bit.
@@ -855,7 +854,6 @@ function finishConcurrentRender(
855854
if (expirationTime === lastSuspendedTime) {
856855
root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
857856
}
858-
flushSuspensePriorityWarningInDEV();
859857

860858
if (
861859
// do not delay if we're inside an act() scope
@@ -1051,7 +1049,7 @@ function performSyncWorkOnRoot(root) {
10511049
stopFinishedWorkLoopTimer();
10521050
root.finishedWork = (root.current.alternate: any);
10531051
root.finishedExpirationTime = expirationTime;
1054-
finishSyncRender(root, workInProgressRootExitStatus, expirationTime);
1052+
finishSyncRender(root);
10551053
}
10561054

10571055
// Before exiting, make sure there's a callback scheduled for the next
@@ -1062,15 +1060,9 @@ function performSyncWorkOnRoot(root) {
10621060
return null;
10631061
}
10641062

1065-
function finishSyncRender(root, exitStatus, expirationTime) {
1063+
function finishSyncRender(root) {
10661064
// Set this to null to indicate there's no in-progress render.
10671065
workInProgressRoot = null;
1068-
1069-
if (__DEV__) {
1070-
if (exitStatus === RootSuspended || exitStatus === RootSuspendedWithDelay) {
1071-
flushSuspensePriorityWarningInDEV();
1072-
}
1073-
}
10741066
commitRoot(root);
10751067
}
10761068

@@ -1274,7 +1266,6 @@ function prepareFreshStack(root, expirationTime) {
12741266

12751267
if (__DEV__) {
12761268
ReactStrictModeWarnings.discardPendingWarnings();
1277-
componentsThatTriggeredHighPriSuspend = null;
12781269
}
12791270
}
12801271

@@ -2859,121 +2850,6 @@ export function warnIfUnmockedScheduler(fiber: Fiber) {
28592850
}
28602851
}
28612852

2862-
let componentsThatTriggeredHighPriSuspend = null;
2863-
export function checkForWrongSuspensePriorityInDEV(sourceFiber: Fiber) {
2864-
if (__DEV__) {
2865-
const currentPriorityLevel = getCurrentPriorityLevel();
2866-
if (
2867-
(sourceFiber.mode & ConcurrentMode) !== NoEffect &&
2868-
(currentPriorityLevel === UserBlockingPriority ||
2869-
currentPriorityLevel === ImmediatePriority)
2870-
) {
2871-
let workInProgressNode = sourceFiber;
2872-
while (workInProgressNode !== null) {
2873-
// Add the component that triggered the suspense
2874-
const current = workInProgressNode.alternate;
2875-
if (current !== null) {
2876-
// TODO: warn component that triggers the high priority
2877-
// suspend is the HostRoot
2878-
switch (workInProgressNode.tag) {
2879-
case ClassComponent:
2880-
// Loop through the component's update queue and see whether the component
2881-
// has triggered any high priority updates
2882-
const updateQueue = current.updateQueue;
2883-
if (updateQueue !== null) {
2884-
let update = updateQueue.baseQueue;
2885-
while (update !== null) {
2886-
const priorityLevel = update.priority;
2887-
if (
2888-
priorityLevel === UserBlockingPriority ||
2889-
priorityLevel === ImmediatePriority
2890-
) {
2891-
if (componentsThatTriggeredHighPriSuspend === null) {
2892-
componentsThatTriggeredHighPriSuspend = new Set([
2893-
getComponentName(workInProgressNode.type),
2894-
]);
2895-
} else {
2896-
componentsThatTriggeredHighPriSuspend.add(
2897-
getComponentName(workInProgressNode.type),
2898-
);
2899-
}
2900-
break;
2901-
}
2902-
update = update.next;
2903-
}
2904-
}
2905-
break;
2906-
case FunctionComponent:
2907-
case ForwardRef:
2908-
case SimpleMemoComponent:
2909-
case Chunk: {
2910-
let firstHook: null | Hook = current.memoizedState;
2911-
// TODO: This just checks the first Hook. Isn't it suppose to check all Hooks?
2912-
if (firstHook !== null && firstHook.baseQueue !== null) {
2913-
let update = firstHook.baseQueue;
2914-
// Loop through the functional component's memoized state to see whether
2915-
// the component has triggered any high pri updates
2916-
while (update !== null) {
2917-
const priority = update.priority;
2918-
if (
2919-
priority === UserBlockingPriority ||
2920-
priority === ImmediatePriority
2921-
) {
2922-
if (componentsThatTriggeredHighPriSuspend === null) {
2923-
componentsThatTriggeredHighPriSuspend = new Set([
2924-
getComponentName(workInProgressNode.type),
2925-
]);
2926-
} else {
2927-
componentsThatTriggeredHighPriSuspend.add(
2928-
getComponentName(workInProgressNode.type),
2929-
);
2930-
}
2931-
break;
2932-
}
2933-
if (update.next === firstHook.baseQueue) {
2934-
break;
2935-
}
2936-
update = update.next;
2937-
}
2938-
}
2939-
break;
2940-
}
2941-
default:
2942-
break;
2943-
}
2944-
}
2945-
workInProgressNode = workInProgressNode.return;
2946-
}
2947-
}
2948-
}
2949-
}
2950-
2951-
function flushSuspensePriorityWarningInDEV() {
2952-
if (__DEV__) {
2953-
if (componentsThatTriggeredHighPriSuspend !== null) {
2954-
const componentNames = [];
2955-
componentsThatTriggeredHighPriSuspend.forEach(name =>
2956-
componentNames.push(name),
2957-
);
2958-
componentsThatTriggeredHighPriSuspend = null;
2959-
2960-
if (componentNames.length > 0) {
2961-
console.error(
2962-
'%s triggered a user-blocking update that suspended.' +
2963-
'\n\n' +
2964-
'The fix is to split the update into multiple parts: a user-blocking ' +
2965-
'update to provide immediate feedback, and another update that ' +
2966-
'triggers the bulk of the changes.' +
2967-
'\n\n' +
2968-
'Refer to the documentation for useTransition to learn how ' +
2969-
'to implement this pattern.', // TODO: Add link to React docs with more information, once it exists
2970-
componentNames.sort().join(', '),
2971-
);
2972-
}
2973-
}
2974-
}
2975-
}
2976-
29772853
function computeThreadID(root, expirationTime) {
29782854
// Interaction threads are unique per root and expiration time.
29792855
return expirationTime * 1000 + root.interactionThreadID;

0 commit comments

Comments
 (0)