mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Cache constants for MP Home NativeModules
Summary: TurboModules doesn't cache invocations of getConstants(). This diff looks at which NativeModules' getConstants() methods gets repeated called in Marketplace, and caches those invocations in JS. Reviewed By: fkgozali Differential Revision: D21874124 fbshipit-source-id: 03d2318e1b6d00236ef707f9f19a640bf8c08786
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fdadff92ab
commit
4e9c428328
@@ -43,7 +43,18 @@ export interface Spec extends TurboModule {
|
||||
}
|
||||
|
||||
const NativeModule: Spec = TurboModuleRegistry.getEnforcing<Spec>('DeviceInfo');
|
||||
let constants = null;
|
||||
|
||||
const NativeDeviceInfo = NativeModule;
|
||||
const NativeDeviceInfo = {
|
||||
getConstants(): {|
|
||||
+Dimensions: DimensionsPayload,
|
||||
+isIPhoneX_deprecated?: boolean,
|
||||
|} {
|
||||
if (constants == null) {
|
||||
constants = NativeModule.getConstants();
|
||||
}
|
||||
return constants;
|
||||
},
|
||||
};
|
||||
|
||||
export default NativeDeviceInfo;
|
||||
|
||||
Reference in New Issue
Block a user