Reputation: 177
Is there a way to have the menu render left-to-right instead of right-to-left? When clicked from the right button of the navigation bar, it's ok; instead from the left button, it's rendered off screen.
Upvotes: 0
Views: 756
Reputation: 177
Solved. During testing i was mixing react-native-menu and react-native-popup-menu. I had both installed. And Webstorm pulled me in imports for both libraries mixing them up.
Upvotes: 0
Reputation: 51861
Here is a short example how to use popup menu with react-navigation. The menu is rendered in both headerRight
and headerLeft
placeholders. It is displayed correctly on both sides:
import React from 'react';
import { AppRegistry, Text } from 'react-native';
import { StackNavigator } from 'react-navigation';
import Menu, {
MenuContext,
MenuOptions,
MenuOption,
MenuTrigger
} from 'react-native-popup-menu';
const NavigatorMenu = ({ navigation }) => (
<Menu>
<MenuTrigger text='...' />
<MenuOptions>
<MenuOption
onSelect={() => navigation.navigate('Page2')}
text='Navigate Page 2'
/>
<MenuOption
onSelect={() => navigation.navigate('Page3')}
text='Navigate Page 3'
/>
</MenuOptions>
</Menu>
);
class Home extends React.Component {
static navigationOptions = ({ navigation }) => ({
title: 'Home',
headerRight: <NavigatorMenu navigation={navigation} />,
headerLeft: <NavigatorMenu navigation={navigation} />,
});
render() {
return <Text>Home Page</Text>;
}
}
const Page2 = () => <Text>2nd Page</Text>;
const Page3 = () => <Text>3rd Page</Text>;
const TopStackNavigator = StackNavigator({
Home: { screen: Home },
Page2: { screen: Page2 },
Page3: { screen: Page3 },
});
const App = () => (
<MenuContext>
<TopStackNavigator />
</MenuContext>
);
AppRegistry.registerComponent('examples', () => App);
It was tested on android with:
Upvotes: 1