Clean up old code for microtasks in Hermes (#44708)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44708

Changelog: [internal]

We had a fallback to use a Hermes internal API if the native module exposing `queueMicrotask` wasn't available. This is no longer necessary as the module is available everywhere we enable the event loop, so we can remove it.

Reviewed By: christophpurrer

Differential Revision: D57922076

fbshipit-source-id: 0ca48abacd77a75ce8559db08f55c78a3e0ec815
This commit is contained in:
Rubén Norte
2024-05-30 04:22:50 -07:00
committed by Facebook GitHub Bot
parent cfbd15aff1
commit e91a577262
2 changed files with 8 additions and 11 deletions
+5 -10
View File
@@ -63,17 +63,12 @@ if (
// mechanism to pass feature flags from RN to React in OSS.
global.RN$enableMicrotasksInReact = true;
polyfillGlobal('queueMicrotask', () => {
const nativeQueueMicrotask =
polyfillGlobal(
'queueMicrotask',
() =>
require('../../src/private/webapis/microtasks/specs/NativeMicrotasks')
.default?.queueMicrotask;
if (nativeQueueMicrotask) {
return nativeQueueMicrotask;
} else {
// For backwards-compatibility
return global.HermesInternal?.enqueueJob;
}
});
.default.queueMicrotask,
);
// We shim the immediate APIs via `queueMicrotask` to maintain the backward
// compatibility.
@@ -16,4 +16,6 @@ export interface Spec extends TurboModule {
+queueMicrotask: (callback: () => mixed) => void;
}
export default (TurboModuleRegistry.get<Spec>('NativeMicrotasksCxx'): ?Spec);
export default (TurboModuleRegistry.getEnforcing<Spec>(
'NativeMicrotasksCxx',
): Spec);