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:
Ramanpreet Nara
2020-06-03 20:48:27 -07:00
committed by Facebook GitHub Bot
parent fdadff92ab
commit 4e9c428328
+12 -1
View File
@@ -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;