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

Point useSubscription to useSyncExternalStore shim #24289

Merged
merged 4 commits into from
Apr 11, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
gaearon committed Apr 11, 2022
commit 67761a9fb628b4f2e61216859a9a395607233d2d
21 changes: 8 additions & 13 deletions packages/use-subscription/src/__tests__/useSubscription-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,13 @@ describe('useSubscription', () => {
renderer.update(<Parent observed={observableA} />);

// Flush everything and ensure that the correct subscribable is used
// We expect the new subscribable to finish rendering,
// But then the updated values from the old subscribable should be used.
expect(Scheduler).toFlushAndYield([
'Grandchild: b-0',
'Child: a-2',
'Grandchild: a-2',
'Child: a-2',
'Grandchild: a-2',
]);
expect(log).toEqual([
'Parent.componentDidUpdate:b-0',
'Parent.componentDidUpdate:a-2',
]);
expect(log).toEqual(['Parent.componentDidUpdate:a-2']);
});

// Updates from the new subscribable should be ignored.
Expand Down Expand Up @@ -628,19 +624,18 @@ describe('useSubscription', () => {
} else {
mutate('C');
}
expect(Scheduler).toFlushAndYieldThrough(['render:first:C']);
expect(Scheduler).toFlushAndYieldThrough([
'render:first:C',
'render:second:C',
]);
if (gate(flags => flags.enableSyncDefaultUpdates)) {
React.startTransition(() => {
mutate('D');
});
} else {
mutate('D');
}
expect(Scheduler).toFlushAndYield([
'render:second:C',
'render:first:D',
'render:second:D',
]);
expect(Scheduler).toFlushAndYield(['render:first:D', 'render:second:D']);

// No more pending updates
jest.runAllTimers();
Expand Down