From 339d9d3afba45bb28073db59e365caea37258891 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Tue, 13 Nov 2018 20:09:21 -0800 Subject: [PATCH] Guard Platform.isTesting under __DEV__ Summary: Testing is a __DEV__ time only, so let's optimize for prod bundles. Reviewed By: ejanzer Differential Revision: D13050583 fbshipit-source-id: a96e35e4d5f3bd09c235c11d4ece3e4d07882de7 --- Libraries/Utilities/Platform.android.js | 7 +++++-- Libraries/Utilities/Platform.ios.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Libraries/Utilities/Platform.android.js b/Libraries/Utilities/Platform.android.js index 714045b93c9d05..6a9feb13753197 100644 --- a/Libraries/Utilities/Platform.android.js +++ b/Libraries/Utilities/Platform.android.js @@ -19,8 +19,11 @@ const Platform = { return constants && constants.Version; }, get isTesting(): boolean { - const constants = NativeModules.PlatformConstants; - return constants && constants.isTesting; + if (__DEV__) { + const constants = NativeModules.PlatformConstants; + return constants && constants.isTesting; + } + return false; }, get isTV(): boolean { const constants = NativeModules.PlatformConstants; diff --git a/Libraries/Utilities/Platform.ios.js b/Libraries/Utilities/Platform.ios.js index a2f97769cc889b..87ee54692aa050 100644 --- a/Libraries/Utilities/Platform.ios.js +++ b/Libraries/Utilities/Platform.ios.js @@ -33,8 +33,11 @@ const Platform = { return constants ? constants.interfaceIdiom === 'tv' : false; }, get isTesting(): boolean { - const constants = NativeModules.PlatformConstants; - return constants && constants.isTesting; + if (__DEV__) { + const constants = NativeModules.PlatformConstants; + return constants && constants.isTesting; + } + return false; }, select: (obj: Object) => ('ios' in obj ? obj.ios : obj.default), };