Skip to content

[v13] chore: remove deprecated stuff #1603

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

Merged
merged 4 commits into from
May 6, 2024
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
25 changes: 0 additions & 25 deletions src/flush-micro-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,3 @@ import { setImmediate } from './helpers/timers';
export function flushMicroTasks() {
return new Promise((resolve) => setImmediate(resolve));
}

/**
* @deprecated To be removed in the next major release.
*/
type Thenable<T> = { then: (callback: () => T) => unknown };

/**
* This legacy implementation of `flushMicroTasks` is used for compatibility with
* older versions of React Native (pre 0.71) which uses Promise polyfil.
*
* For users with older version of React Native there is a workaround of using our own
* Jest preset instead the `react-native` one, but requiring such change would be a
* breaking change for existing users.
*
* @deprecated To be removed in the next major release.
*/
export function flushMicroTasksLegacy(): Thenable<void> {
return {
// using "thenable" instead of a Promise, because otherwise it breaks when
// using "modern" fake timers
then(resolve) {
setImmediate(resolve);
},
};
}
4 changes: 2 additions & 2 deletions src/helpers/wrap-async.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* istanbul ignore file */

import act, { getIsReactActEnvironment, setReactActEnvironment } from '../act';
import { flushMicroTasksLegacy } from '../flush-micro-tasks';
import { flushMicroTasks } from '../flush-micro-tasks';
import { checkReactVersionAtLeast } from '../react-versions';

/**
Expand All @@ -18,7 +18,7 @@ export async function wrapAsync<Result>(callback: () => Promise<Result>): Promis
try {
const result = await callback();
// Flush the microtask queue before restoring the `act` environment
await flushMicroTasksLegacy();
await flushMicroTasks();
return result;
} finally {
setReactActEnvironment(previousActEnvironment);
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cleanup } from './pure';
import { flushMicroTasksLegacy } from './flush-micro-tasks';
import { flushMicroTasks } from './flush-micro-tasks';
import { getIsReactActEnvironment, setReactActEnvironment } from './act';

if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
Expand All @@ -11,7 +11,7 @@ if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
if (typeof afterEach === 'function') {
// eslint-disable-next-line no-undef
afterEach(async () => {
await flushMicroTasksLegacy();
await flushMicroTasks();
cleanup();
});
}
Expand Down
Loading
Loading