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

Replace SuspenseConfig object with an integer #19706

Merged
merged 1 commit into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
} from 'react-reconciler/src/ReactInternalTypes';
import type {OpaqueIDType} from 'react-reconciler/src/ReactFiberHostConfig';

import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig';
import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberTransition';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this new file name seems more generic than before, is there something more specific?

ReactFiberCurrentTransitionState? ReactFiberCurrentTransitionValue? ReactFiberTransitionUpdate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named it this way because I anticipate we're going to put more stuff in that same module

import {NoMode} from 'react-reconciler/src/ReactTypeOfMode';

import ErrorStackParser from 'error-stack-parser';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/ReactPartialRendererHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
MutableSourceSubscribeFn,
ReactContext,
} from 'shared/ReactTypes';
import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig';
import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberTransition';
import type PartialRenderer from './ReactPartialRenderer';

import {validateContextBounds} from './ReactPartialRendererContext';
Expand Down
10 changes: 3 additions & 7 deletions packages/react-reconciler/src/ReactFiberClassComponent.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import {
requestUpdateLane,
scheduleUpdateOnFiber,
} from './ReactFiberWorkLoop.new';
import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';
import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';

import {disableLogs, reenableLogs} from 'shared/ConsolePatchingDev';
Expand Down Expand Up @@ -196,8 +195,7 @@ const classComponentUpdater = {
enqueueSetState(inst, payload, callback) {
const fiber = getInstance(inst);
const eventTime = requestEventTime();
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

const update = createUpdate(eventTime, lane);
update.payload = payload;
Expand Down Expand Up @@ -227,8 +225,7 @@ const classComponentUpdater = {
enqueueReplaceState(inst, payload, callback) {
const fiber = getInstance(inst);
const eventTime = requestEventTime();
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

const update = createUpdate(eventTime, lane);
update.tag = ReplaceState;
Expand Down Expand Up @@ -260,8 +257,7 @@ const classComponentUpdater = {
enqueueForceUpdate(inst, callback) {
const fiber = getInstance(inst);
const eventTime = requestEventTime();
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

const update = createUpdate(eventTime, lane);
update.tag = ForceUpdate;
Expand Down
10 changes: 3 additions & 7 deletions packages/react-reconciler/src/ReactFiberClassComponent.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import {
requestUpdateLane,
scheduleUpdateOnFiber,
} from './ReactFiberWorkLoop.old';
import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';
import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';

import {disableLogs, reenableLogs} from 'shared/ConsolePatchingDev';
Expand Down Expand Up @@ -196,8 +195,7 @@ const classComponentUpdater = {
enqueueSetState(inst, payload, callback) {
const fiber = getInstance(inst);
const eventTime = requestEventTime();
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

const update = createUpdate(eventTime, lane);
update.payload = payload;
Expand Down Expand Up @@ -227,8 +225,7 @@ const classComponentUpdater = {
enqueueReplaceState(inst, payload, callback) {
const fiber = getInstance(inst);
const eventTime = requestEventTime();
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

const update = createUpdate(eventTime, lane);
update.tag = ReplaceState;
Expand Down Expand Up @@ -260,8 +257,7 @@ const classComponentUpdater = {
enqueueForceUpdate(inst, callback) {
const fiber = getInstance(inst);
const eventTime = requestEventTime();
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

const update = createUpdate(eventTime, lane);
update.tag = ForceUpdate;
Expand Down
42 changes: 19 additions & 23 deletions packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
import type {Fiber, Dispatcher} from './ReactInternalTypes';
import type {Lanes, Lane} from './ReactFiberLane';
import type {HookEffectTag} from './ReactHookEffectTags';
import type {SuspenseConfig} from './ReactFiberSuspenseConfig';
import type {SuspenseConfig} from './ReactFiberTransition';
import type {ReactPriorityLevel} from './ReactInternalTypes';
import type {FiberRoot} from './ReactInternalTypes';
import type {OpaqueIDType} from './ReactFiberHostConfig';
Expand Down Expand Up @@ -70,7 +70,6 @@ import invariant from 'shared/invariant';
import getComponentName from 'shared/getComponentName';
import is from 'shared/objectIs';
import {markWorkInProgressReceivedUpdate} from './ReactFiberBeginWork.new';
import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';
import {
UserBlockingPriority,
NormalPriority,
Expand Down Expand Up @@ -1003,8 +1002,7 @@ function useMutableSource<Source, Snapshot>(
if (!is(snapshot, maybeNewSnapshot)) {
setSnapshot(maybeNewSnapshot);

const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);
markRootMutableRead(root, lane);
}
// If the source mutated between render and now,
Expand All @@ -1024,8 +1022,7 @@ function useMutableSource<Source, Snapshot>(
latestSetSnapshot(latestGetSnapshot(source._source));

// Record a pending mutable source update with the same expiration time.
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

markRootMutableRead(root, lane);
} catch (error) {
Expand Down Expand Up @@ -1441,12 +1438,12 @@ function mountDeferredValue<T>(
): T {
const [prevValue, setValue] = mountState(value);
mountEffect(() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setValue(value);
} finally {
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
}, [value, config]);
return prevValue;
Expand All @@ -1458,12 +1455,12 @@ function updateDeferredValue<T>(
): T {
const [prevValue, setValue] = updateState(value);
updateEffect(() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setValue(value);
} finally {
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
}, [value, config]);
return prevValue;
Expand All @@ -1475,12 +1472,12 @@ function rerenderDeferredValue<T>(
): T {
const [prevValue, setValue] = rerenderState(value);
updateEffect(() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setValue(value);
} finally {
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
}, [value, config]);
return prevValue;
Expand Down Expand Up @@ -1509,16 +1506,16 @@ function startTransition(setPending, config, callback) {
runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
if (decoupleUpdatePriorityFromScheduler) {
setCurrentUpdateLanePriority(previousLanePriority);
}
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
Expand All @@ -1535,13 +1532,13 @@ function startTransition(setPending, config, callback) {
runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
Expand Down Expand Up @@ -1685,8 +1682,7 @@ function dispatchAction<S, A>(
}

const eventTime = requestEventTime();
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

const update: Update<S, A> = {
lane,
Expand Down
42 changes: 19 additions & 23 deletions packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
import type {Fiber, Dispatcher} from './ReactInternalTypes';
import type {Lanes, Lane} from './ReactFiberLane';
import type {HookEffectTag} from './ReactHookEffectTags';
import type {SuspenseConfig} from './ReactFiberSuspenseConfig';
import type {SuspenseConfig} from './ReactFiberTransition';
import type {ReactPriorityLevel} from './ReactInternalTypes';
import type {FiberRoot} from './ReactInternalTypes';
import type {OpaqueIDType} from './ReactFiberHostConfig';
Expand Down Expand Up @@ -69,7 +69,6 @@ import invariant from 'shared/invariant';
import getComponentName from 'shared/getComponentName';
import is from 'shared/objectIs';
import {markWorkInProgressReceivedUpdate} from './ReactFiberBeginWork.old';
import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';
import {
UserBlockingPriority,
NormalPriority,
Expand Down Expand Up @@ -1002,8 +1001,7 @@ function useMutableSource<Source, Snapshot>(
if (!is(snapshot, maybeNewSnapshot)) {
setSnapshot(maybeNewSnapshot);

const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);
markRootMutableRead(root, lane);
}
// If the source mutated between render and now,
Expand All @@ -1023,8 +1021,7 @@ function useMutableSource<Source, Snapshot>(
latestSetSnapshot(latestGetSnapshot(source._source));

// Record a pending mutable source update with the same expiration time.
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

markRootMutableRead(root, lane);
} catch (error) {
Expand Down Expand Up @@ -1440,12 +1437,12 @@ function mountDeferredValue<T>(
): T {
const [prevValue, setValue] = mountState(value);
mountEffect(() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setValue(value);
} finally {
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
}, [value, config]);
return prevValue;
Expand All @@ -1457,12 +1454,12 @@ function updateDeferredValue<T>(
): T {
const [prevValue, setValue] = updateState(value);
updateEffect(() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setValue(value);
} finally {
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
}, [value, config]);
return prevValue;
Expand All @@ -1474,12 +1471,12 @@ function rerenderDeferredValue<T>(
): T {
const [prevValue, setValue] = rerenderState(value);
updateEffect(() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setValue(value);
} finally {
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
}, [value, config]);
return prevValue;
Expand Down Expand Up @@ -1508,16 +1505,16 @@ function startTransition(setPending, config, callback) {
runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
if (decoupleUpdatePriorityFromScheduler) {
setCurrentUpdateLanePriority(previousLanePriority);
}
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
Expand All @@ -1534,13 +1531,13 @@ function startTransition(setPending, config, callback) {
runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const previousConfig = ReactCurrentBatchConfig.suspense;
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
ReactCurrentBatchConfig.suspense = previousConfig;
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
Expand Down Expand Up @@ -1683,8 +1680,7 @@ function dispatchAction<S, A>(
}

const eventTime = requestEventTime();
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);
const lane = requestUpdateLane(fiber);

const update: Update<S, A> = {
lane,
Expand Down
6 changes: 2 additions & 4 deletions packages/react-reconciler/src/ReactFiberReconciler.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ import {
getCurrentUpdateLanePriority,
setCurrentUpdateLanePriority,
} from './ReactFiberLane';
import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';
import {
scheduleRefresh,
scheduleRoot,
Expand Down Expand Up @@ -266,8 +265,7 @@ export function updateContainer(
warnIfNotScopedWithMatchingAct(current);
}
}
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(current, suspenseConfig);
const lane = requestUpdateLane(current);

if (enableSchedulingProfiler) {
markRenderScheduled(lane);
Expand Down Expand Up @@ -427,7 +425,7 @@ export function attemptHydrationAtCurrentPriority(fiber: Fiber): void {
return;
}
const eventTime = requestEventTime();
const lane = requestUpdateLane(fiber, null);
const lane = requestUpdateLane(fiber);
scheduleUpdateOnFiber(fiber, lane, eventTime);
markRetryLaneIfNotHydrated(fiber, lane);
}
Expand Down
Loading