diff --git a/Libraries/Utilities/Platform.android.js b/Libraries/Utilities/Platform.android.js
index d7e672b33b8..e228adc98d2 100644
--- a/Libraries/Utilities/Platform.android.js
+++ b/Libraries/Utilities/Platform.android.js
@@ -18,21 +18,25 @@ export type PlatformSelectSpec = {
};
const Platform = {
+ __constants: null,
OS: 'android',
get Version() {
- return NativePlatformConstantsAndroid.getConstants().Version;
+ return this.constants.Version;
},
get constants() {
- return NativePlatformConstantsAndroid.getConstants();
+ if (this.__constants == null) {
+ this.__constants = NativePlatformConstantsAndroid.getConstants();
+ }
+ return this.__constants;
},
get isTesting(): boolean {
if (__DEV__) {
- return NativePlatformConstantsAndroid.getConstants().isTesting;
+ return this.constants.isTesting;
}
return false;
},
get isTV(): boolean {
- return NativePlatformConstantsAndroid.getConstants().uiMode === 'tv';
+ return this.constants.uiMode === 'tv';
},
select: (spec: PlatformSelectSpec): A | D =>
'android' in spec ? spec.android : spec.default,
diff --git a/Libraries/Utilities/Platform.ios.js b/Libraries/Utilities/Platform.ios.js
index f558755c6f0..0bdb6d35a62 100644
--- a/Libraries/Utilities/Platform.ios.js
+++ b/Libraries/Utilities/Platform.ios.js
@@ -18,15 +18,19 @@ export type PlatformSelectSpec = {
};
const Platform = {
+ __constants: null,
OS: 'ios',
get Version() {
- return NativePlatformConstantsIOS.getConstants().osVersion;
+ return this.constants.osVersion;
},
get constants() {
- return NativePlatformConstantsIOS.getConstants();
+ if (this.__constants == null) {
+ this.__constants = NativePlatformConstantsIOS.getConstants();
+ }
+ return this.__constants;
},
get isPad() {
- return NativePlatformConstantsIOS.getConstants().interfaceIdiom === 'pad';
+ return this.constants.interfaceIdiom === 'pad';
},
/**
* Deprecated, use `isTV` instead.
@@ -35,11 +39,11 @@ const Platform = {
return Platform.isTV;
},
get isTV() {
- return NativePlatformConstantsIOS.getConstants().interfaceIdiom === 'tv';
+ return this.constants.interfaceIdiom === 'tv';
},
get isTesting(): boolean {
if (__DEV__) {
- return NativePlatformConstantsIOS.getConstants().isTesting;
+ return this.constants.isTesting;
}
return false;
},