Skip to content

Commit

Permalink
fix(iOS): crash when using Android only options (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
IamMHC authored and bradbumbalough committed Dec 13, 2019
1 parent 39fc431 commit 8016008
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/ActionSheet/index.ios.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from 'react';

import { ActionSheetIOS, View, ViewProps } from 'react-native';

import { ActionSheetIOSOptions } from '../types';

interface Props {
Expand All @@ -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);
}
Expand Down

0 comments on commit 8016008

Please sign in to comment.