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:
parent
0e1d4ecbb7
commit
e1451caddd
|
@ -15,7 +15,8 @@ const NativeModules = require('NativeModules');
|
|||
import type {TurboModule} from 'RCTExport';
|
||||
import invariant from 'invariant';
|
||||
|
||||
// TODO
|
||||
const turboModuleProxy = global.__turboModuleProxy;
|
||||
|
||||
function get<T: TurboModule>(name: string): ?T {
|
||||
// Backward compatibility layer during migration.
|
||||
const legacyModule = NativeModules[name];
|
||||
|
@ -23,8 +24,12 @@ function get<T: TurboModule>(name: string): ?T {
|
|||
return ((legacyModule: any): T);
|
||||
}
|
||||
|
||||
const module: ?T = global.__turboModuleProxy(name);
|
||||
return module;
|
||||
if (turboModuleProxy != null) {
|
||||
const module: ?T = turboModuleProxy(name);
|
||||
return module;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getEnforcing<T: TurboModule>(name: string): T {
|
||||
|
|
Loading…
Reference in New Issue