GeezerVison is showing github.com — Remove fakeCallbackNode (#20799) · react/react@47dd9f4
File treeExpand file treeCollapse file tree Open diff view settings packages/react-reconciler/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.new.js +4-6Lines changed: 4 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -726,7 +726,8 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) { | 726 | 726 | // TODO: Temporary until we confirm this warning is not fired. | 727 | 727 | if ( | 728 | 728 | existingCallbackNode == null && | 729 | | - existingCallbackPriority !== InputDiscreteLanePriority | | 729 | + existingCallbackPriority !== InputDiscreteLanePriority && | | 730 | + existingCallbackPriority !== SyncLanePriority | 730 | 731 | ) { | 731 | 732 | console.error( | 732 | 733 | '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) { | 747 | 748 | if (newCallbackPriority === SyncLanePriority) { | 748 | 749 | // Special case: Sync React callbacks are scheduled on a special | 749 | 750 | // internal queue | 750 | | - | 751 | | - // TODO: After enableDiscreteEventMicroTasks lands, we can remove the fake node. | 752 | | - newCallbackNode = scheduleSyncCallback( | 753 | | - performSyncWorkOnRoot.bind(null, root), | 754 | | - ); | | 751 | + scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); | | 752 | + newCallbackNode = null; | 755 | 753 | } else if (newCallbackPriority === SyncBatchedLanePriority) { | 756 | 754 | newCallbackNode = scheduleCallback( | 757 | 755 | ImmediateSchedulerPriority, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.old.js +4-6Lines changed: 4 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -726,7 +726,8 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) { | 726 | 726 | // TODO: Temporary until we confirm this warning is not fired. | 727 | 727 | if ( | 728 | 728 | existingCallbackNode == null && | 729 | | - existingCallbackPriority !== InputDiscreteLanePriority | | 729 | + existingCallbackPriority !== InputDiscreteLanePriority && | | 730 | + existingCallbackPriority !== SyncLanePriority | 730 | 731 | ) { | 731 | 732 | console.error( | 732 | 733 | '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) { | 747 | 748 | if (newCallbackPriority === SyncLanePriority) { | 748 | 749 | // Special case: Sync React callbacks are scheduled on a special | 749 | 750 | // internal queue | 750 | | - | 751 | | - // TODO: After enableDiscreteEventMicroTasks lands, we can remove the fake node. | 752 | | - newCallbackNode = scheduleSyncCallback( | 753 | | - performSyncWorkOnRoot.bind(null, root), | 754 | | - ); | | 751 | + scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); | | 752 | + newCallbackNode = null; | 755 | 753 | } else if (newCallbackPriority === SyncBatchedLanePriority) { | 756 | 754 | newCallbackNode = scheduleCallback( | 757 | 755 | ImmediateSchedulerPriority, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/SchedulerWithReactIntegration.new.js +3-6Lines changed: 3 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -57,8 +57,6 @@ export type SchedulerCallback = (isSync: boolean) => SchedulerCallback | null; | 57 | 57 |
| 58 | 58 | type SchedulerCallbackOptions = {timeout?: number, ...}; | 59 | 59 |
| 60 | | -const fakeCallbackNode = {}; | 61 | | - | 62 | 60 | // Except for NoPriority, these correspond to Scheduler priorities. We use | 63 | 61 | // ascending numbers so we can compare them like numbers. They start at 90 to | 64 | 62 | // avoid clashing with Scheduler's priorities. | @@ -147,6 +145,8 @@ export function scheduleSyncCallback(callback: SchedulerCallback) { | 147 | 145 | if (syncQueue === null) { | 148 | 146 | syncQueue = [callback]; | 149 | 147 | // Flush the queue in the next tick, at the earliest. | | 148 | + // TODO: Figure out how to remove this It's only here as a last resort if we | | 149 | + // forget to explicitly flush. | 150 | 150 | immediateQueueCallbackNode = Scheduler_scheduleCallback( | 151 | 151 | Scheduler_ImmediatePriority, | 152 | 152 | flushSyncCallbackQueueImpl, | @@ -156,13 +156,10 @@ export function scheduleSyncCallback(callback: SchedulerCallback) { | 156 | 156 | // we already scheduled one when we created the queue. | 157 | 157 | syncQueue.push(callback); | 158 | 158 | } | 159 | | - return fakeCallbackNode; | 160 | 159 | } | 161 | 160 |
| 162 | 161 | export function cancelCallback(callbackNode: mixed) { | 163 | | - if (callbackNode !== fakeCallbackNode) { | 164 | | - Scheduler_cancelCallback(callbackNode); | 165 | | - } | | 162 | + Scheduler_cancelCallback(callbackNode); | 166 | 163 | } | 167 | 164 |
| 168 | 165 | export function flushSyncCallbackQueue() { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/SchedulerWithReactIntegration.old.js +3-6Lines changed: 3 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -57,8 +57,6 @@ export type SchedulerCallback = (isSync: boolean) => SchedulerCallback | null; | 57 | 57 |
| 58 | 58 | type SchedulerCallbackOptions = {timeout?: number, ...}; | 59 | 59 |
| 60 | | -const fakeCallbackNode = {}; | 61 | | - | 62 | 60 | // Except for NoPriority, these correspond to Scheduler priorities. We use | 63 | 61 | // ascending numbers so we can compare them like numbers. They start at 90 to | 64 | 62 | // avoid clashing with Scheduler's priorities. | @@ -147,6 +145,8 @@ export function scheduleSyncCallback(callback: SchedulerCallback) { | 147 | 145 | if (syncQueue === null) { | 148 | 146 | syncQueue = [callback]; | 149 | 147 | // Flush the queue in the next tick, at the earliest. | | 148 | + // TODO: Figure out how to remove this It's only here as a last resort if we | | 149 | + // forget to explicitly flush. | 150 | 150 | immediateQueueCallbackNode = Scheduler_scheduleCallback( | 151 | 151 | Scheduler_ImmediatePriority, | 152 | 152 | flushSyncCallbackQueueImpl, | @@ -156,13 +156,10 @@ export function scheduleSyncCallback(callback: SchedulerCallback) { | 156 | 156 | // we already scheduled one when we created the queue. | 157 | 157 | syncQueue.push(callback); | 158 | 158 | } | 159 | | - return fakeCallbackNode; | 160 | 159 | } | 161 | 160 |
| 162 | 161 | export function cancelCallback(callbackNode: mixed) { | 163 | | - if (callbackNode !== fakeCallbackNode) { | 164 | | - Scheduler_cancelCallback(callbackNode); | 165 | | - } | | 162 | + Scheduler_cancelCallback(callbackNode); | 166 | 163 | } | 167 | 164 |
| 168 | 165 | export function flushSyncCallbackQueue() { | |
|