fix(iOS): crash when using Android only options (#144)

This commit is contained in:
Hashir Ch authored and Brad Bumbalough committed 2019-12-13 07:15:56 -06:00
1 parent 39fc431c97
commit 8016008781
1 file changed
+11 -4
+11 -4
View File
@@ -1,5 +1,7 @@
import * as React from 'react';
import { ActionSheetIOS, View, ViewProps } from 'react-native';
import { ActionSheetIOSOptions } from '../types';
interface Props {
@@ -18,12 +20,17 @@ export default class ActionSheet extends React.Component<Props> {
);
}
showActionSheetWithOptions(options: ActionSheetIOSOptions, onSelect: onSelect) {
showActionSheetWithOptions(dataOptions: ActionSheetIOSOptions, onSelect: onSelect) {
// ...dataOptions include other keys which use in android and web, thats why `Android-Only options` Crash on IOS
const { cancelButtonIndex, destructiveButtonIndex, options, tintColor } = dataOptions;
const iosOptions: ActionSheetIOSOptions = {
...options,
cancelButtonIndex,
destructiveButtonIndex,
options,
tintColor,
// A null title or message on iOS causes a crash
title: options.title || undefined,
message: options.message || undefined,
title: dataOptions.title || undefined,
message: dataOptions.message || undefined,
};
ActionSheetIOS.showActionSheetWithOptions(iosOptions, onSelect);
}