mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Remove fakeCallbackNode (#20799)
Don't need this, because sync tasks are never cancelled. We can do the same thing we do for microtask callbacks.
This commit is contained in:
@@ -726,7 +726,8 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
|
||||
// TODO: Temporary until we confirm this warning is not fired.
|
||||
if (
|
||||
existingCallbackNode == null &&
|
||||
existingCallbackPriority !== InputDiscreteLanePriority
|
||||
existingCallbackPriority !== InputDiscreteLanePriority &&
|
||||
existingCallbackPriority !== SyncLanePriority
|
||||
) {
|
||||
console.error(
|
||||
'Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.',
|
||||
@@ -747,11 +748,8 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
|
||||
if (newCallbackPriority === SyncLanePriority) {
|
||||
// Special case: Sync React callbacks are scheduled on a special
|
||||
// internal queue
|
||||
|
||||
// TODO: After enableDiscreteEventMicroTasks lands, we can remove the fake node.
|
||||
newCallbackNode = scheduleSyncCallback(
|
||||
performSyncWorkOnRoot.bind(null, root),
|
||||
);
|
||||
scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
|
||||
newCallbackNode = null;
|
||||
} else if (newCallbackPriority === SyncBatchedLanePriority) {
|
||||
newCallbackNode = scheduleCallback(
|
||||
ImmediateSchedulerPriority,
|
||||
|
||||
@@ -726,7 +726,8 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
|
||||
// TODO: Temporary until we confirm this warning is not fired.
|
||||
if (
|
||||
existingCallbackNode == null &&
|
||||
existingCallbackPriority !== InputDiscreteLanePriority
|
||||
existingCallbackPriority !== InputDiscreteLanePriority &&
|
||||
existingCallbackPriority !== SyncLanePriority
|
||||
) {
|
||||
console.error(
|
||||
'Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.',
|
||||
@@ -747,11 +748,8 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
|
||||
if (newCallbackPriority === SyncLanePriority) {
|
||||
// Special case: Sync React callbacks are scheduled on a special
|
||||
// internal queue
|
||||
|
||||
// TODO: After enableDiscreteEventMicroTasks lands, we can remove the fake node.
|
||||
newCallbackNode = scheduleSyncCallback(
|
||||
performSyncWorkOnRoot.bind(null, root),
|
||||
);
|
||||
scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
|
||||
newCallbackNode = null;
|
||||
} else if (newCallbackPriority === SyncBatchedLanePriority) {
|
||||
newCallbackNode = scheduleCallback(
|
||||
ImmediateSchedulerPriority,
|
||||
|
||||
@@ -57,8 +57,6 @@ export type SchedulerCallback = (isSync: boolean) => SchedulerCallback | null;
|
||||
|
||||
type SchedulerCallbackOptions = {timeout?: number, ...};
|
||||
|
||||
const fakeCallbackNode = {};
|
||||
|
||||
// Except for NoPriority, these correspond to Scheduler priorities. We use
|
||||
// ascending numbers so we can compare them like numbers. They start at 90 to
|
||||
// avoid clashing with Scheduler's priorities.
|
||||
@@ -147,6 +145,8 @@ export function scheduleSyncCallback(callback: SchedulerCallback) {
|
||||
if (syncQueue === null) {
|
||||
syncQueue = [callback];
|
||||
// Flush the queue in the next tick, at the earliest.
|
||||
// TODO: Figure out how to remove this It's only here as a last resort if we
|
||||
// forget to explicitly flush.
|
||||
immediateQueueCallbackNode = Scheduler_scheduleCallback(
|
||||
Scheduler_ImmediatePriority,
|
||||
flushSyncCallbackQueueImpl,
|
||||
@@ -156,13 +156,10 @@ export function scheduleSyncCallback(callback: SchedulerCallback) {
|
||||
// we already scheduled one when we created the queue.
|
||||
syncQueue.push(callback);
|
||||
}
|
||||
return fakeCallbackNode;
|
||||
}
|
||||
|
||||
export function cancelCallback(callbackNode: mixed) {
|
||||
if (callbackNode !== fakeCallbackNode) {
|
||||
Scheduler_cancelCallback(callbackNode);
|
||||
}
|
||||
Scheduler_cancelCallback(callbackNode);
|
||||
}
|
||||
|
||||
export function flushSyncCallbackQueue() {
|
||||
|
||||
@@ -57,8 +57,6 @@ export type SchedulerCallback = (isSync: boolean) => SchedulerCallback | null;
|
||||
|
||||
type SchedulerCallbackOptions = {timeout?: number, ...};
|
||||
|
||||
const fakeCallbackNode = {};
|
||||
|
||||
// Except for NoPriority, these correspond to Scheduler priorities. We use
|
||||
// ascending numbers so we can compare them like numbers. They start at 90 to
|
||||
// avoid clashing with Scheduler's priorities.
|
||||
@@ -147,6 +145,8 @@ export function scheduleSyncCallback(callback: SchedulerCallback) {
|
||||
if (syncQueue === null) {
|
||||
syncQueue = [callback];
|
||||
// Flush the queue in the next tick, at the earliest.
|
||||
// TODO: Figure out how to remove this It's only here as a last resort if we
|
||||
// forget to explicitly flush.
|
||||
immediateQueueCallbackNode = Scheduler_scheduleCallback(
|
||||
Scheduler_ImmediatePriority,
|
||||
flushSyncCallbackQueueImpl,
|
||||
@@ -156,13 +156,10 @@ export function scheduleSyncCallback(callback: SchedulerCallback) {
|
||||
// we already scheduled one when we created the queue.
|
||||
syncQueue.push(callback);
|
||||
}
|
||||
return fakeCallbackNode;
|
||||
}
|
||||
|
||||
export function cancelCallback(callbackNode: mixed) {
|
||||
if (callbackNode !== fakeCallbackNode) {
|
||||
Scheduler_cancelCallback(callbackNode);
|
||||
}
|
||||
Scheduler_cancelCallback(callbackNode);
|
||||
}
|
||||
|
||||
export function flushSyncCallbackQueue() {
|
||||
|
||||
Reference in New Issue
Block a user