Skip to content

Commit

Permalink
provide an anchor to our actionsheet (facebook#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
HeyImChris authored Mar 20, 2020
1 parent 36306e3 commit b25c2ef
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion RNTester/js/ActionSheetMacOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var {
StyleSheet,
Text,
View,
findNodeHandle,
} = ReactNative;

var BUTTONS = [
Expand All @@ -32,10 +33,12 @@ class ActionSheetExample extends React.Component<{}, $FlowFixMeState> {
clicked: 'none',
};

anchorRef = React.createRef();

render() {
return (
<View>
<Text onPress={this.showActionSheet} style={style.button}>
<Text onPress={this.showActionSheet} style={style.button} ref={this.anchorRef}>
Click to show the ActionSheet
</Text>
<Text>
Expand All @@ -49,6 +52,9 @@ class ActionSheetExample extends React.Component<{}, $FlowFixMeState> {
ActionSheetIOS.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
anchor: this.anchorRef.current
? findNodeHandle(this.anchorRef.current)
: undefined,
destructiveButtonIndex: DESTRUCTIVE_INDEX,
},
(buttonIndex) => {
Expand Down

0 comments on commit b25c2ef

Please sign in to comment.