GeezerVison is showing github.com — Clean up timeoutMs-related implementation details (#19704) · react/react@1eaafc9
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/ReactFiberClassComponent.new.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -199,7 +199,7 @@ const classComponentUpdater = { | 199 | 199 | const suspenseConfig = requestCurrentSuspenseConfig(); | 200 | 200 | const lane = requestUpdateLane(fiber, suspenseConfig); | 201 | 201 |
| 202 | | - const update = createUpdate(eventTime, lane, suspenseConfig); | | 202 | + const update = createUpdate(eventTime, lane); | 203 | 203 | update.payload = payload; | 204 | 204 | if (callback !== undefined && callback !== null) { | 205 | 205 | if (__DEV__) { | @@ -230,7 +230,7 @@ const classComponentUpdater = { | 230 | 230 | const suspenseConfig = requestCurrentSuspenseConfig(); | 231 | 231 | const lane = requestUpdateLane(fiber, suspenseConfig); | 232 | 232 |
| 233 | | - const update = createUpdate(eventTime, lane, suspenseConfig); | | 233 | + const update = createUpdate(eventTime, lane); | 234 | 234 | update.tag = ReplaceState; | 235 | 235 | update.payload = payload; | 236 | 236 |
| @@ -263,7 +263,7 @@ const classComponentUpdater = { | 263 | 263 | const suspenseConfig = requestCurrentSuspenseConfig(); | 264 | 264 | const lane = requestUpdateLane(fiber, suspenseConfig); | 265 | 265 |
| 266 | | - const update = createUpdate(eventTime, lane, suspenseConfig); | | 266 | + const update = createUpdate(eventTime, lane); | 267 | 267 | update.tag = ForceUpdate; | 268 | 268 |
| 269 | 269 | if (callback !== undefined && callback !== null) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberClassComponent.old.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -199,7 +199,7 @@ const classComponentUpdater = { | 199 | 199 | const suspenseConfig = requestCurrentSuspenseConfig(); | 200 | 200 | const lane = requestUpdateLane(fiber, suspenseConfig); | 201 | 201 |
| 202 | | - const update = createUpdate(eventTime, lane, suspenseConfig); | | 202 | + const update = createUpdate(eventTime, lane); | 203 | 203 | update.payload = payload; | 204 | 204 | if (callback !== undefined && callback !== null) { | 205 | 205 | if (__DEV__) { | @@ -230,7 +230,7 @@ const classComponentUpdater = { | 230 | 230 | const suspenseConfig = requestCurrentSuspenseConfig(); | 231 | 231 | const lane = requestUpdateLane(fiber, suspenseConfig); | 232 | 232 |
| 233 | | - const update = createUpdate(eventTime, lane, suspenseConfig); | | 233 | + const update = createUpdate(eventTime, lane); | 234 | 234 | update.tag = ReplaceState; | 235 | 235 | update.payload = payload; | 236 | 236 |
| @@ -263,7 +263,7 @@ const classComponentUpdater = { | 263 | 263 | const suspenseConfig = requestCurrentSuspenseConfig(); | 264 | 264 | const lane = requestUpdateLane(fiber, suspenseConfig); | 265 | 265 |
| 266 | | - const update = createUpdate(eventTime, lane, suspenseConfig); | | 266 | + const update = createUpdate(eventTime, lane); | 267 | 267 | update.tag = ForceUpdate; | 268 | 268 |
| 269 | 269 | if (callback !== undefined && callback !== null) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberHooks.new.js -21Lines changed: 0 additions & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -63,7 +63,6 @@ import { | 63 | 63 | warnIfNotCurrentlyActingEffectsInDEV, | 64 | 64 | warnIfNotCurrentlyActingUpdatesInDev, | 65 | 65 | warnIfNotScopedWithMatchingAct, | 66 | | - markRenderEventTimeAndConfig, | 67 | 66 | markSkippedUpdateLanes, | 68 | 67 | } from './ReactFiberWorkLoop.new'; | 69 | 68 |
| @@ -97,11 +96,7 @@ import {markStateUpdateScheduled} from './SchedulingProfiler'; | 97 | 96 | const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals; | 98 | 97 |
| 99 | 98 | type Update<S, A> = {| | 100 | | - // TODO: Temporary field. Will remove this by storing a map of | 101 | | - // transition -> start time on the root. | 102 | | - eventTime: number, | 103 | 99 | lane: Lane, | 104 | | - suspenseConfig: null | SuspenseConfig, | 105 | 100 | action: A, | 106 | 101 | eagerReducer: ((S, A) => S) | null, | 107 | 102 | eagerState: S | null, | @@ -715,17 +710,13 @@ function updateReducer<S, I, A>( | 715 | 710 | let newBaseQueueLast = null; | 716 | 711 | let update = first; | 717 | 712 | do { | 718 | | - const suspenseConfig = update.suspenseConfig; | 719 | 713 | const updateLane = update.lane; | 720 | | - const updateEventTime = update.eventTime; | 721 | 714 | if (!isSubsetOfLanes(renderLanes, updateLane)) { | 722 | 715 | // Priority is insufficient. Skip this update. If this is the first | 723 | 716 | // skipped update, the previous update/state is the new base | 724 | 717 | // update/state. | 725 | 718 | const clone: Update<S, A> = { | 726 | | - eventTime: updateEventTime, | 727 | 719 | lane: updateLane, | 728 | | - suspenseConfig: suspenseConfig, | 729 | 720 | action: update.action, | 730 | 721 | eagerReducer: update.eagerReducer, | 731 | 722 | eagerState: update.eagerState, | @@ -750,12 +741,10 @@ function updateReducer<S, I, A>( | 750 | 741 |
| 751 | 742 | if (newBaseQueueLast !== null) { | 752 | 743 | const clone: Update<S, A> = { | 753 | | - eventTime: updateEventTime, | 754 | 744 | // This update is going to be committed so we never want uncommit | 755 | 745 | // it. Using NoLane works because 0 is a subset of all bitmasks, so | 756 | 746 | // this will never be skipped by the check above. | 757 | 747 | lane: NoLane, | 758 | | - suspenseConfig: update.suspenseConfig, | 759 | 748 | action: update.action, | 760 | 749 | eagerReducer: update.eagerReducer, | 761 | 750 | eagerState: update.eagerState, | @@ -764,14 +753,6 @@ function updateReducer<S, I, A>( | 764 | 753 | newBaseQueueLast = newBaseQueueLast.next = clone; | 765 | 754 | } | 766 | 755 |
| 767 | | - // Mark the event time of this update as relevant to this render pass. | 768 | | - // TODO: This should ideally use the true event time of this update rather than | 769 | | - // its priority which is a derived and not reverseable value. | 770 | | - // TODO: We should skip this update if it was already committed but currently | 771 | | - // we have no way of detecting the difference between a committed and suspended | 772 | | - // update here. | 773 | | - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig); | 774 | | - | 775 | 756 | // Process this update. | 776 | 757 | if (update.eagerReducer === reducer) { | 777 | 758 | // If this update was processed eagerly, and its reducer matches the | @@ -1708,9 +1689,7 @@ function dispatchAction<S, A>( | 1708 | 1689 | const lane = requestUpdateLane(fiber, suspenseConfig); | 1709 | 1690 |
| 1710 | 1691 | const update: Update<S, A> = { | 1711 | | - eventTime, | 1712 | 1692 | lane, | 1713 | | - suspenseConfig, | 1714 | 1693 | action, | 1715 | 1694 | eagerReducer: null, | 1716 | 1695 | eagerState: null, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberHooks.old.js -21Lines changed: 0 additions & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -62,7 +62,6 @@ import { | 62 | 62 | warnIfNotCurrentlyActingEffectsInDEV, | 63 | 63 | warnIfNotCurrentlyActingUpdatesInDev, | 64 | 64 | warnIfNotScopedWithMatchingAct, | 65 | | - markRenderEventTimeAndConfig, | 66 | 65 | markSkippedUpdateLanes, | 67 | 66 | } from './ReactFiberWorkLoop.old'; | 68 | 67 |
| @@ -96,11 +95,7 @@ import {markStateUpdateScheduled} from './SchedulingProfiler'; | 96 | 95 | const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals; | 97 | 96 |
| 98 | 97 | type Update<S, A> = {| | 99 | | - // TODO: Temporary field. Will remove this by storing a map of | 100 | | - // transition -> start time on the root. | 101 | | - eventTime: number, | 102 | 98 | lane: Lane, | 103 | | - suspenseConfig: null | SuspenseConfig, | 104 | 99 | action: A, | 105 | 100 | eagerReducer: ((S, A) => S) | null, | 106 | 101 | eagerState: S | null, | @@ -714,17 +709,13 @@ function updateReducer<S, I, A>( | 714 | 709 | let newBaseQueueLast = null; | 715 | 710 | let update = first; | 716 | 711 | do { | 717 | | - const suspenseConfig = update.suspenseConfig; | 718 | 712 | const updateLane = update.lane; | 719 | | - const updateEventTime = update.eventTime; | 720 | 713 | if (!isSubsetOfLanes(renderLanes, updateLane)) { | 721 | 714 | // Priority is insufficient. Skip this update. If this is the first | 722 | 715 | // skipped update, the previous update/state is the new base | 723 | 716 | // update/state. | 724 | 717 | const clone: Update<S, A> = { | 725 | | - eventTime: updateEventTime, | 726 | 718 | lane: updateLane, | 727 | | - suspenseConfig: suspenseConfig, | 728 | 719 | action: update.action, | 729 | 720 | eagerReducer: update.eagerReducer, | 730 | 721 | eagerState: update.eagerState, | @@ -749,12 +740,10 @@ function updateReducer<S, I, A>( | 749 | 740 |
| 750 | 741 | if (newBaseQueueLast !== null) { | 751 | 742 | const clone: Update<S, A> = { | 752 | | - eventTime: updateEventTime, | 753 | 743 | // This update is going to be committed so we never want uncommit | 754 | 744 | // it. Using NoLane works because 0 is a subset of all bitmasks, so | 755 | 745 | // this will never be skipped by the check above. | 756 | 746 | lane: NoLane, | 757 | | - suspenseConfig: update.suspenseConfig, | 758 | 747 | action: update.action, | 759 | 748 | eagerReducer: update.eagerReducer, | 760 | 749 | eagerState: update.eagerState, | @@ -763,14 +752,6 @@ function updateReducer<S, I, A>( | 763 | 752 | newBaseQueueLast = newBaseQueueLast.next = clone; | 764 | 753 | } | 765 | 754 |
| 766 | | - // Mark the event time of this update as relevant to this render pass. | 767 | | - // TODO: This should ideally use the true event time of this update rather than | 768 | | - // its priority which is a derived and not reversible value. | 769 | | - // TODO: We should skip this update if it was already committed but currently | 770 | | - // we have no way of detecting the difference between a committed and suspended | 771 | | - // update here. | 772 | | - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig); | 773 | | - | 774 | 755 | // Process this update. | 775 | 756 | if (update.eagerReducer === reducer) { | 776 | 757 | // If this update was processed eagerly, and its reducer matches the | @@ -1706,9 +1687,7 @@ function dispatchAction<S, A>( | 1706 | 1687 | const lane = requestUpdateLane(fiber, suspenseConfig); | 1707 | 1688 |
| 1708 | 1689 | const update: Update<S, A> = { | 1709 | | - eventTime, | 1710 | 1690 | lane, | 1711 | | - suspenseConfig, | 1712 | 1691 | action, | 1713 | 1692 | eagerReducer: null, | 1714 | 1693 | eagerState: null, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberLane.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -461,6 +461,9 @@ export function includesNonIdleWork(lanes: Lanes) { | 461 | 461 | export function includesOnlyRetries(lanes: Lanes) { | 462 | 462 | return (lanes & RetryLanes) === lanes; | 463 | 463 | } | | 464 | +export function includesOnlyTransitions(lanes: Lanes) { | | 465 | + return (lanes & TransitionLanes) === lanes; | | 466 | +} | 464 | 467 |
| 465 | 468 | // To ensure consistency across multiple updates in the same event, this should | 466 | 469 | // be a pure function, so that it always returns the same lane for given inputs. | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberNewContext.new.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -212,7 +212,6 @@ export function propagateContextChange( | 212 | 212 | const update = createUpdate( | 213 | 213 | NoTimestamp, | 214 | 214 | pickArbitraryLane(renderLanes), | 215 | | - null, | 216 | 215 | ); | 217 | 216 | update.tag = ForceUpdate; | 218 | 217 | // TODO: Because we don't have a work-in-progress, this will add the | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberNewContext.old.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -212,7 +212,6 @@ export function propagateContextChange( | 212 | 212 | const update = createUpdate( | 213 | 213 | NoTimestamp, | 214 | 214 | pickArbitraryLane(renderLanes), | 215 | | - null, | 216 | 215 | ); | 217 | 216 | update.tag = ForceUpdate; | 218 | 217 | // TODO: Because we don't have a work-in-progress, this will add the | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberReconciler.new.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -297,7 +297,7 @@ export function updateContainer( | 297 | 297 | } | 298 | 298 | } | 299 | 299 |
| 300 | | - const update = createUpdate(eventTime, lane, suspenseConfig); | | 300 | + const update = createUpdate(eventTime, lane); | 301 | 301 | // Caution: React DevTools currently depends on this property | 302 | 302 | // being called "element". | 303 | 303 | update.payload = {element}; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberReconciler.old.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -297,7 +297,7 @@ export function updateContainer( | 297 | 297 | } | 298 | 298 | } | 299 | 299 |
| 300 | | - const update = createUpdate(eventTime, lane, suspenseConfig); | | 300 | + const update = createUpdate(eventTime, lane); | 301 | 301 | // Caution: React DevTools currently depends on this property | 302 | 302 | // being called "element". | 303 | 303 | update.payload = {element}; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberThrow.new.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -76,7 +76,7 @@ function createRootErrorUpdate( | 76 | 76 | errorInfo: CapturedValue<mixed>, | 77 | 77 | lane: Lane, | 78 | 78 | ): Update<mixed> { | 79 | | - const update = createUpdate(NoTimestamp, lane, null); | | 79 | + const update = createUpdate(NoTimestamp, lane); | 80 | 80 | // Unmount the root by rendering null. | 81 | 81 | update.tag = CaptureUpdate; | 82 | 82 | // Caution: React DevTools currently depends on this property | @@ -95,7 +95,7 @@ function createClassErrorUpdate( | 95 | 95 | errorInfo: CapturedValue<mixed>, | 96 | 96 | lane: Lane, | 97 | 97 | ): Update<mixed> { | 98 | | - const update = createUpdate(NoTimestamp, lane, null); | | 98 | + const update = createUpdate(NoTimestamp, lane); | 99 | 99 | update.tag = CaptureUpdate; | 100 | 100 | const getDerivedStateFromError = fiber.type.getDerivedStateFromError; | 101 | 101 | if (typeof getDerivedStateFromError === 'function') { | @@ -274,7 +274,7 @@ function throwException( | 274 | 274 | // When we try rendering again, we should not reuse the current fiber, | 275 | 275 | // since it's known to be in an inconsistent state. Use a force update to | 276 | 276 | // prevent a bail out. | 277 | | - const update = createUpdate(NoTimestamp, SyncLane, null); | | 277 | + const update = createUpdate(NoTimestamp, SyncLane); | 278 | 278 | update.tag = ForceUpdate; | 279 | 279 | enqueueUpdate(sourceFiber, update); | 280 | 280 | } | |
|