我在headerRight
这样的部分设置菜单:
const Tab1 = createStackNavigator({
S1: {
screen: CouponsScreen,
navigationOptions: () => ({
title: `Test`,
headerStyle: styles.headerStyle,
headerTitleStyle: styles.headerTitleStyle,
headerRight: (
<CustomMenu/>
),
}),
},
});
我的菜单控件使用状态来可视化:
//state itself
state = {
visible: false,
};
//class methods
_openMenu = () => this.setState({visible: true});
_closeMenu = () => this.setState({visible: false});
//render() part:
<Provider>
<View>
<Menu
visible={this.state.visible}
onDismiss={this._closeMenu}
anchor={
<DotsIcon
onPress={this._openMenu}
name="dots-three-vertical"
color={Colors.WHITE}
size={20}
/>
}>
...
这基本上是来自https://callstack.github.io/react-native-paper/menu.html的标准示例。知道为什么它不起作用吗?我的意思是显示控件 DotsIcon,但单击时没有任何反应。