Skip to content
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
5 changes: 3 additions & 2 deletions packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ import {
disableCommentsAsDOMContainers,
enableSuspenseyImages,
enableSrcObject,
enableViewTransition,
} from 'shared/ReactFeatureFlags';
import {
HostComponent,
Expand Down Expand Up @@ -5112,7 +5113,7 @@ export function isHostHoistableType(
}

export function maySuspendCommit(type: Type, props: Props): boolean {
if (!enableSuspenseyImages) {
if (!enableSuspenseyImages && !enableViewTransition) {
return false;
}
// Suspensey images are the default, unless you opt-out of with either
Expand Down Expand Up @@ -5206,7 +5207,7 @@ export function suspendInstance(
type: Type,
props: Props,
): void {
if (!enableSuspenseyImages) {
if (!enableSuspenseyImages && !enableViewTransition) {
return;
}
if (suspendedState === null) {
Expand Down
7 changes: 7 additions & 0 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
disableLegacyMode,
enableObjectFiber,
enableViewTransition,
enableSuspenseyImages,
} from 'shared/ReactFeatureFlags';
import {NoFlags, Placement, StaticMask} from './ReactFiberFlags';
import {ConcurrentRoot} from './ReactRootTags';
Expand Down Expand Up @@ -89,6 +90,7 @@ import {
StrictLegacyMode,
StrictEffectsMode,
NoStrictPassiveEffectsMode,
SuspenseyImagesMode,
} from './ReactTypeOfMode';
import {
REACT_FORWARD_REF_TYPE,
Expand Down Expand Up @@ -875,6 +877,11 @@ export function createFiberFromViewTransition(
lanes: Lanes,
key: null | string,
): Fiber {
if (!enableSuspenseyImages) {
// Render a ViewTransition component opts into SuspenseyImages mode even
// when the flag is off.
mode |= SuspenseyImagesMode;
}
const fiber = createFiber(ViewTransitionComponent, pendingProps, key, mode);
fiber.elementType = REACT_VIEW_TRANSITION_TYPE;
fiber.lanes = lanes;
Expand Down
14 changes: 11 additions & 3 deletions packages/react-reconciler/src/ReactFiberCompleteWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
disableLegacyMode,
enableSiblingPrerendering,
enableViewTransition,
enableSuspenseyImages,
} from 'shared/ReactFeatureFlags';

import {now} from './Scheduler';
Expand Down Expand Up @@ -77,7 +78,12 @@ import {
ViewTransitionComponent,
ActivityComponent,
} from './ReactWorkTags';
import {NoMode, ConcurrentMode, ProfileMode} from './ReactTypeOfMode';
import {
NoMode,
ConcurrentMode,
ProfileMode,
SuspenseyImagesMode,
} from './ReactTypeOfMode';
import {
Placement,
Update,
Expand Down Expand Up @@ -555,9 +561,11 @@ function preloadInstanceAndSuspendIfNeeded(
renderLanes: Lanes,
) {
const maySuspend =
oldProps === null
(enableSuspenseyImages ||
(workInProgress.mode & SuspenseyImagesMode) !== NoMode) &&
(oldProps === null
? maySuspendCommit(type, newProps)
: maySuspendCommitOnUpdate(type, oldProps, newProps);
: maySuspendCommitOnUpdate(type, oldProps, newProps));

if (!maySuspend) {
// If this flag was set previously, we can remove it. The flag
Expand Down
5 changes: 4 additions & 1 deletion packages/react-reconciler/src/ReactTypeOfMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ export type TypeOfMode = number;
export const NoMode = /* */ 0b0000000;
// TODO: Remove ConcurrentMode by reading from the root tag instead
export const ConcurrentMode = /* */ 0b0000001;
export const ProfileMode = /* */ 0b0000010;
export const ProfileMode = /* */ 0b0000010;
//export const DebugTracingMode = /* */ 0b0000100; // Removed
export const StrictLegacyMode = /* */ 0b0001000;
export const StrictEffectsMode = /* */ 0b0010000;
export const NoStrictPassiveEffectsMode = /* */ 0b1000000;
// Keep track of if we're in a SuspenseyImages eligible subtree.
// TODO: Remove this when enableSuspenseyImages ship where it's always on.
export const SuspenseyImagesMode = /* */ 0b0100000;
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('ReactSuspenseyCommitPhase', () => {
);
}

// @gate enableSuspenseyImages
it('suspend commit during initial mount', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
Expand All @@ -70,6 +71,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});

// @gate enableSuspenseyImages
it('suspend commit during update', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
Expand Down Expand Up @@ -105,6 +107,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});

// @gate enableSuspenseyImages
it('suspend commit during initial mount at the root', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
Expand All @@ -121,6 +124,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});

// @gate enableSuspenseyImages
it('suspend commit during update at the root', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
Expand All @@ -147,6 +151,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});

// @gate enableSuspenseyImages
it('suspend commit during urgent initial mount', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
Expand All @@ -165,6 +170,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});

// @gate enableSuspenseyImages
it('suspend commit during urgent update', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
Expand Down Expand Up @@ -203,6 +209,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});

// @gate enableSuspenseyImages
it('suspends commit during urgent initial mount at the root', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
Expand All @@ -217,6 +224,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});

// @gate enableSuspenseyImages
it('suspends commit during urgent update at the root', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
Expand All @@ -239,6 +247,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});

// @gate enableSuspenseyImages
it('does suspend commit during urgent initial mount at the root when sync rendering', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
Expand All @@ -256,6 +265,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});

// @gate enableSuspenseyImages
it('does suspend commit during urgent update at the root when sync rendering', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
Expand Down Expand Up @@ -283,6 +293,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});

// @gate enableSuspenseyImages
it('an urgent update interrupts a suspended commit', async () => {
const root = ReactNoop.createRoot();

Expand All @@ -305,6 +316,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput('Something else');
});

// @gate enableSuspenseyImages
it('a transition update interrupts a suspended commit', async () => {
const root = ReactNoop.createRoot();

Expand All @@ -329,7 +341,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput('Something else');
});

// @gate enableSuspenseList
// @gate enableSuspenseList && enableSuspenseyImages
it('demonstrate current behavior when used with SuspenseList (not ideal)', async () => {
function App() {
return (
Expand Down Expand Up @@ -381,6 +393,7 @@ describe('ReactSuspenseyCommitPhase', () => {
);
});

// @gate enableSuspenseyImages
it('avoid triggering a fallback if resource loads immediately', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
Expand Down Expand Up @@ -429,7 +442,7 @@ describe('ReactSuspenseyCommitPhase', () => {
);
});

// @gate enableActivity
// @gate enableActivity && enableSuspenseyImages
it("host instances don't suspend during prerendering, but do suspend when they are revealed", async () => {
function More() {
Scheduler.log('More');
Expand Down Expand Up @@ -493,7 +506,7 @@ describe('ReactSuspenseyCommitPhase', () => {
});

// FIXME: Should pass with `enableYieldingBeforePassive`
// @gate !enableYieldingBeforePassive
// @gate !enableYieldingBeforePassive && enableSuspenseyImages
it('runs passive effects after suspended commit resolves', async () => {
function Effect() {
React.useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const enableGestureTransition = __EXPERIMENTAL__;

export const enableScrollEndPolyfill = __EXPERIMENTAL__;

export const enableSuspenseyImages = __EXPERIMENTAL__;
export const enableSuspenseyImages = false;

export const enableSrcObject = __EXPERIMENTAL__;

Expand Down