mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-12 19:48:30 +08:00
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:
committed by
Facebook Github Bot
parent
0ceefb40d5
commit
1e6f5344d6
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user