mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook GitHub Bot
parent
cfbd15aff1
commit
e91a577262
+5
-10
@@ -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.
|
||||
|
||||
+3
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user