diff --git a/Libraries/Utilities/Platform.android.js b/Libraries/Utilities/Platform.android.js
index fd0cb70d49be6a..4a4de286938344 100644
--- a/Libraries/Utilities/Platform.android.js
+++ b/Libraries/Utilities/Platform.android.js
@@ -12,8 +12,9 @@
import NativePlatformConstantsAndroid from './NativePlatformConstantsAndroid';
-export type PlatformSelectSpec = {
+export type PlatformSelectSpec = {
android?: A,
+ native?: N,
default?: D,
};
@@ -53,8 +54,12 @@ const Platform = {
get isTV(): boolean {
return this.constants.uiMode === 'tv';
},
- select: (spec: PlatformSelectSpec): A | D =>
- 'android' in spec ? spec.android : spec.default,
+ select: (spec: PlatformSelectSpec): A | N | D =>
+ 'android' in spec
+ ? spec.android
+ : 'native' in spec
+ ? spec.native
+ : spec.default,
};
module.exports = Platform;
diff --git a/Libraries/Utilities/Platform.ios.js b/Libraries/Utilities/Platform.ios.js
index 38666839daf484..ed933099e6e615 100644
--- a/Libraries/Utilities/Platform.ios.js
+++ b/Libraries/Utilities/Platform.ios.js
@@ -12,8 +12,9 @@
import NativePlatformConstantsIOS from './NativePlatformConstantsIOS';
-export type PlatformSelectSpec = {
+export type PlatformSelectSpec = {
default?: D,
+ native?: N,
ios?: I,
};
@@ -59,8 +60,8 @@ const Platform = {
}
return false;
},
- select: (spec: PlatformSelectSpec): D | I =>
- 'ios' in spec ? spec.ios : spec.default,
+ select: (spec: PlatformSelectSpec): D | N | I =>
+ 'ios' in spec ? spec.ios : 'native' in spec ? spec.native : spec.default,
};
module.exports = Platform;
diff --git a/Libraries/Utilities/__tests__/Platform-test.js b/Libraries/Utilities/__tests__/Platform-test.js
index dd1a85caf5cd72..2dd11b0edcd9e5 100644
--- a/Libraries/Utilities/__tests__/Platform-test.js
+++ b/Libraries/Utilities/__tests__/Platform-test.js
@@ -27,5 +27,17 @@ describe('Platform', () => {
expect(PlatformIOS.select(obj)).toEqual(obj.ios);
expect(PlatformAndroid.select(obj)).toEqual(obj.android);
});
+
+ it('should return native value if no specific value was found', () => {
+ const obj = {native: 'native', default: 'default'};
+ expect(PlatformIOS.select(obj)).toEqual(obj.native);
+ expect(PlatformAndroid.select(obj)).toEqual(obj.native);
+ });
+
+ it('should return default value if no specific value was found', () => {
+ const obj = {default: 'default'};
+ expect(PlatformIOS.select(obj)).toEqual(obj.default);
+ expect(PlatformAndroid.select(obj)).toEqual(obj.default);
+ });
});
});