Skip to content

Commit b25c2ef

Browse files
authored
provide an anchor to our actionsheet (#261)
1 parent 36306e3 commit b25c2ef

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

RNTester/js/ActionSheetMacOSExample.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var {
1515
StyleSheet,
1616
Text,
1717
View,
18+
findNodeHandle,
1819
} = ReactNative;
1920

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

36+
anchorRef = React.createRef();
37+
3538
render() {
3639
return (
3740
<View>
38-
<Text onPress={this.showActionSheet} style={style.button}>
41+
<Text onPress={this.showActionSheet} style={style.button} ref={this.anchorRef}>
3942
Click to show the ActionSheet
4043
</Text>
4144
<Text>
@@ -49,6 +52,9 @@ class ActionSheetExample extends React.Component<{}, $FlowFixMeState> {
4952
ActionSheetIOS.showActionSheetWithOptions({
5053
options: BUTTONS,
5154
cancelButtonIndex: CANCEL_INDEX,
55+
anchor: this.anchorRef.current
56+
? findNodeHandle(this.anchorRef.current)
57+
: undefined,
5258
destructiveButtonIndex: DESTRUCTIVE_INDEX,
5359
},
5460
(buttonIndex) => {

0 commit comments

Comments
 (0)