mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-30 22:12:42 +08:00
Only call __turboModuleProxy when it exists
Summary: `__turboModuleProxy` doesn't exist if you're not in the TurboModules QE. If such is the case, then we should just return null when `TurboModuleRegistry.get` is called. Reviewed By: fkgozali Differential Revision: D13937143 fbshipit-source-id: d3f11c52b7cbecaefba675d714f0d67236071389
This commit is contained in:
committed by
Facebook Github Bot
parent
0e1d4ecbb7
commit
e1451caddd
@@ -15,7 +15,8 @@ const NativeModules = require('NativeModules');
|
|||||||
import type {TurboModule} from 'RCTExport';
|
import type {TurboModule} from 'RCTExport';
|
||||||
import invariant from 'invariant';
|
import invariant from 'invariant';
|
||||||
|
|
||||||
// TODO
|
const turboModuleProxy = global.__turboModuleProxy;
|
||||||
|
|
||||||
function get<T: TurboModule>(name: string): ?T {
|
function get<T: TurboModule>(name: string): ?T {
|
||||||
// Backward compatibility layer during migration.
|
// Backward compatibility layer during migration.
|
||||||
const legacyModule = NativeModules[name];
|
const legacyModule = NativeModules[name];
|
||||||
@@ -23,8 +24,12 @@ function get<T: TurboModule>(name: string): ?T {
|
|||||||
return ((legacyModule: any): T);
|
return ((legacyModule: any): T);
|
||||||
}
|
}
|
||||||
|
|
||||||
const module: ?T = global.__turboModuleProxy(name);
|
if (turboModuleProxy != null) {
|
||||||
return module;
|
const module: ?T = turboModuleProxy(name);
|
||||||
|
return module;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnforcing<T: TurboModule>(name: string): T {
|
function getEnforcing<T: TurboModule>(name: string): T {
|
||||||
|
|||||||
Reference in New Issue
Block a user