Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Expiration Time Model #17669

Closed
wants to merge 9 commits into from
5 changes: 3 additions & 2 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ import {
calculateChangedBits,
scheduleWorkOnParentPath,
} from './ReactFiberNewContext';
import {resetHooks, renderWithHooks, bailoutHooks} from './ReactFiberHooks';
import {renderWithHooks, bailoutHooks} from './ReactFiberHooks';
import {stopProfilerTimerIfRunning} from './ReactProfilerTimer';
import {
getMaskedContext,
Expand Down Expand Up @@ -1407,7 +1407,8 @@ function mountIndeterminateComponent(
workInProgress.tag = ClassComponent;

// Throw out any hooks that were used.
resetHooks();
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;

// Push context providers early to prevent context stack mismatches.
// During mounting we don't know the child context yet as the instance doesn't exist.
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberClassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const classComponentUpdater = {
suspenseConfig,
);

const update = createUpdate(expirationTime, suspenseConfig);
const update = createUpdate(currentTime, expirationTime, suspenseConfig);
update.payload = payload;
if (callback !== undefined && callback !== null) {
if (__DEV__) {
Expand All @@ -212,7 +212,7 @@ const classComponentUpdater = {
suspenseConfig,
);

const update = createUpdate(expirationTime, suspenseConfig);
const update = createUpdate(currentTime, expirationTime, suspenseConfig);
update.tag = ReplaceState;
update.payload = payload;

Expand All @@ -236,7 +236,7 @@ const classComponentUpdater = {
suspenseConfig,
);

const update = createUpdate(expirationTime, suspenseConfig);
const update = createUpdate(currentTime, expirationTime, suspenseConfig);
update.tag = ForceUpdate;

if (callback !== undefined && callback !== null) {
Expand Down
11 changes: 4 additions & 7 deletions packages/react-reconciler/src/ReactFiberExpirationTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,13 @@ export function computeAsyncExpiration(
);
}

export function computeSuspenseExpiration(
export function computeSuspenseTimeout(
currentTime: ExpirationTime,
timeoutMs: number,
): ExpirationTime {
// TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
return computeExpirationBucket(
currentTime,
timeoutMs,
LOW_PRIORITY_BATCH_SIZE,
);
const currentTimeMs = expirationTimeToMs(currentTime);
const deadlineMs = currentTimeMs + timeoutMs;
return msToExpirationTime(deadlineMs);
}

// We intentionally set a higher expiration time for interactive updates in
Expand Down
Loading