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
Original file line number Diff line number Diff line change
Expand Up @@ -491,4 +491,46 @@ describe('ReactSuspenseyCommitPhase', () => {
</>,
);
});

// FIXME: Should pass with `enableYieldingBeforePassive`
// @gate !enableYieldingBeforePassive
it('runs passive effects after suspended commit resolves', async () => {
function Effect() {
React.useEffect(() => {
Scheduler.log('flush effect');
});
return <Text text="render effect" />;
}

const root = ReactNoop.createRoot();

await act(() => {
root.render(
<Suspense fallback={<Text text="Loading..." />}>
<Effect />
<SuspenseyImage src="A" />
</Suspense>,
);
});

assertLog([
'render effect',
'Image requested [A]',
'Loading...',
'render effect',
]);
expect(root).toMatchRenderedOutput('Loading...');

await act(() => {
resolveSuspenseyThing('A');
});

assertLog(['flush effect']);
expect(root).toMatchRenderedOutput(
<>
{'render effect'}
<suspensey-thing src="A" />
</>,
);
});
});
3 changes: 2 additions & 1 deletion packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export const enableLegacyFBSupport = false;
// -----------------------------------------------------------------------------

// Yield to the browser event loop and not just the scheduler event loop before passive effects.
export const enableYieldingBeforePassive = __EXPERIMENTAL__;
// Fix gated tests that fail with this flag enabled before turning it back on.
export const enableYieldingBeforePassive = false;

export const enableLegacyCache = __EXPERIMENTAL__;

Expand Down
Loading