avoid double lookup of a nativemodule when resolving turbomodule

Summary: A simple optimization to not access `NativeModules` property twice.

Reviewed By: RSNara

Differential Revision: D13908128

fbshipit-source-id: d41cd5f855fb0176170d6bdc3ac93df5593eeca5
This commit is contained in:
Kevin Gozali
2019-01-31 16:54:37 -08:00
committed by Facebook Github Bot
parent 0ceefb40d5
commit 1e6f5344d6

View File

@@ -17,8 +17,9 @@ import {NativeModules} from 'react-native';
// TODO
function get<T: TurboModule>(name: string): ?T {
// Backward compatibility layer during migration.
if (NativeModules[name] != null) {
return ((NativeModules[name]: any): T);
const legacyModule = NativeModules[name];
if (legacyModule != null) {
return ((legacyModule: any): T);
}
const module: ?T = global.__turboModuleProxy(name);