GeezerVison is showing github.com — Delete immediateQueueCallbackNode (#20980) · react/react@754e307
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 +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -89,6 +89,7 @@ import { | 89 | 89 | getCurrentEventPriority, | 90 | 90 | supportsMicrotasks, | 91 | 91 | errorHydratingContainer, | | 92 | + scheduleMicrotask, | 92 | 93 | } from './ReactFiberHostConfig'; | 93 | 94 |
| 94 | 95 | import { | @@ -696,6 +697,13 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) { | 696 | 697 | // Special case: Sync React callbacks are scheduled on a special | 697 | 698 | // internal queue | 698 | 699 | scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); | | 700 | + if (supportsMicrotasks) { | | 701 | + // Flush the queue in a microtask. | | 702 | + scheduleMicrotask(flushSyncCallbackQueue); | | 703 | + } else { | | 704 | + // Flush the queue in an Immediate task. | | 705 | + scheduleCallback(ImmediateSchedulerPriority, flushSyncCallbackQueue); | | 706 | + } | 699 | 707 | newCallbackNode = null; | 700 | 708 | } else if (newCallbackPriority === SyncBatchedLanePriority) { | 701 | 709 | newCallbackNode = scheduleCallback( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.old.js +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -89,6 +89,7 @@ import { | 89 | 89 | getCurrentEventPriority, | 90 | 90 | supportsMicrotasks, | 91 | 91 | errorHydratingContainer, | | 92 | + scheduleMicrotask, | 92 | 93 | } from './ReactFiberHostConfig'; | 93 | 94 |
| 94 | 95 | import { | @@ -696,6 +697,13 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) { | 696 | 697 | // Special case: Sync React callbacks are scheduled on a special | 697 | 698 | // internal queue | 698 | 699 | scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); | | 700 | + if (supportsMicrotasks) { | | 701 | + // Flush the queue in a microtask. | | 702 | + scheduleMicrotask(flushSyncCallbackQueue); | | 703 | + } else { | | 704 | + // Flush the queue in an Immediate task. | | 705 | + scheduleCallback(ImmediateSchedulerPriority, flushSyncCallbackQueue); | | 706 | + } | 699 | 707 | newCallbackNode = null; | 700 | 708 | } else if (newCallbackPriority === SyncBatchedLanePriority) { | 701 | 709 | newCallbackNode = scheduleCallback( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/SchedulerWithReactIntegration.new.js +1-24Lines changed: 1 addition & 24 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,6 @@ import { | 20 | 20 | getCurrentUpdateLanePriority, | 21 | 21 | setCurrentUpdateLanePriority, | 22 | 22 | } from './ReactFiberLane.new'; | 23 | | -import {scheduleMicrotask, supportsMicrotasks} from './ReactFiberHostConfig'; | 24 | 23 |
| 25 | 24 | const { | 26 | 25 | unstable_scheduleCallback: Scheduler_scheduleCallback, | @@ -71,7 +70,6 @@ export const requestPaint = | 71 | 70 | Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : () => {}; | 72 | 71 |
| 73 | 72 | let syncQueue: Array<SchedulerCallback> | null = null; | 74 | | -let immediateQueueCallbackNode: mixed | null = null; | 75 | 73 | let isFlushingSyncQueue: boolean = false; | 76 | 74 | const initialTimeMs: number = Scheduler_now(); | 77 | 75 |
| @@ -133,19 +131,6 @@ export function scheduleSyncCallback(callback: SchedulerCallback) { | 133 | 131 | // the next tick, or earlier if something calls `flushSyncCallbackQueue`. | 134 | 132 | if (syncQueue === null) { | 135 | 133 | syncQueue = [callback]; | 136 | | - | 137 | | - // TODO: Figure out how to remove this It's only here as a last resort if we | 138 | | - // forget to explicitly flush. | 139 | | - if (supportsMicrotasks) { | 140 | | - // Flush the queue in a microtask. | 141 | | - scheduleMicrotask(flushSyncCallbackQueueImpl); | 142 | | - } else { | 143 | | - // Flush the queue in the next tick. | 144 | | - immediateQueueCallbackNode = Scheduler_scheduleCallback( | 145 | | - Scheduler_ImmediatePriority, | 146 | | - flushSyncCallbackQueueImpl, | 147 | | - ); | 148 | | - } | 149 | 134 | } else { | 150 | 135 | // Push onto existing queue. Don't need to schedule a callback because | 151 | 136 | // we already scheduled one when we created the queue. | @@ -158,15 +143,6 @@ export function cancelCallback(callbackNode: mixed) { | 158 | 143 | } | 159 | 144 |
| 160 | 145 | export function flushSyncCallbackQueue() { | 161 | | - if (immediateQueueCallbackNode !== null) { | 162 | | - const node = immediateQueueCallbackNode; | 163 | | - immediateQueueCallbackNode = null; | 164 | | - Scheduler_cancelCallback(node); | 165 | | - } | 166 | | - flushSyncCallbackQueueImpl(); | 167 | | -} | 168 | | - | 169 | | -function flushSyncCallbackQueueImpl() { | 170 | 146 | if (!isFlushingSyncQueue && syncQueue !== null) { | 171 | 147 | // Prevent re-entrancy. | 172 | 148 | isFlushingSyncQueue = true; | @@ -199,4 +175,5 @@ function flushSyncCallbackQueueImpl() { | 199 | 175 | isFlushingSyncQueue = false; | 200 | 176 | } | 201 | 177 | } | | 178 | + return null; | 202 | 179 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/SchedulerWithReactIntegration.old.js +1-24Lines changed: 1 addition & 24 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,6 @@ import { | 20 | 20 | getCurrentUpdateLanePriority, | 21 | 21 | setCurrentUpdateLanePriority, | 22 | 22 | } from './ReactFiberLane.old'; | 23 | | -import {scheduleMicrotask, supportsMicrotasks} from './ReactFiberHostConfig'; | 24 | 23 |
| 25 | 24 | const { | 26 | 25 | unstable_scheduleCallback: Scheduler_scheduleCallback, | @@ -71,7 +70,6 @@ export const requestPaint = | 71 | 70 | Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : () => {}; | 72 | 71 |
| 73 | 72 | let syncQueue: Array<SchedulerCallback> | null = null; | 74 | | -let immediateQueueCallbackNode: mixed | null = null; | 75 | 73 | let isFlushingSyncQueue: boolean = false; | 76 | 74 | const initialTimeMs: number = Scheduler_now(); | 77 | 75 |
| @@ -133,19 +131,6 @@ export function scheduleSyncCallback(callback: SchedulerCallback) { | 133 | 131 | // the next tick, or earlier if something calls `flushSyncCallbackQueue`. | 134 | 132 | if (syncQueue === null) { | 135 | 133 | syncQueue = [callback]; | 136 | | - | 137 | | - // TODO: Figure out how to remove this It's only here as a last resort if we | 138 | | - // forget to explicitly flush. | 139 | | - if (supportsMicrotasks) { | 140 | | - // Flush the queue in a microtask. | 141 | | - scheduleMicrotask(flushSyncCallbackQueueImpl); | 142 | | - } else { | 143 | | - // Flush the queue in the next tick. | 144 | | - immediateQueueCallbackNode = Scheduler_scheduleCallback( | 145 | | - Scheduler_ImmediatePriority, | 146 | | - flushSyncCallbackQueueImpl, | 147 | | - ); | 148 | | - } | 149 | 134 | } else { | 150 | 135 | // Push onto existing queue. Don't need to schedule a callback because | 151 | 136 | // we already scheduled one when we created the queue. | @@ -158,15 +143,6 @@ export function cancelCallback(callbackNode: mixed) { | 158 | 143 | } | 159 | 144 |
| 160 | 145 | export function flushSyncCallbackQueue() { | 161 | | - if (immediateQueueCallbackNode !== null) { | 162 | | - const node = immediateQueueCallbackNode; | 163 | | - immediateQueueCallbackNode = null; | 164 | | - Scheduler_cancelCallback(node); | 165 | | - } | 166 | | - flushSyncCallbackQueueImpl(); | 167 | | -} | 168 | | - | 169 | | -function flushSyncCallbackQueueImpl() { | 170 | 146 | if (!isFlushingSyncQueue && syncQueue !== null) { | 171 | 147 | // Prevent re-entrancy. | 172 | 148 | isFlushingSyncQueue = true; | @@ -199,4 +175,5 @@ function flushSyncCallbackQueueImpl() { | 199 | 175 | isFlushingSyncQueue = false; | 200 | 176 | } | 201 | 177 | } | | 178 | + return null; | 202 | 179 | } |
|