I am using 'react-native-popup-menu'
<MenuOptions customStyles={{ optionText: styles.text }}>
<MenuOption value="History" text='History'
onPress={()=>{this.props.navigation.navigate('History')}} />
<MenuOption value="Logout" text='Logout' onPress={()=>{this.props.navigation.navigate('Login')}}/>
</MenuOptions>
I want to navigate when I click on any of the menu options to another screen, how can I achieve it?
Looking at the docs from the Library, MenuOption
takes an onSelect
prop rather than onPress
From their example:
<MenuOptions>
<MenuOption **onSelect**={() => alert(`Save`)} text='Save' />
<MenuOption **onSelect**={() => alert(`Delete`)} >
<Text style={{color: 'red'}}>Delete</Text>
</MenuOption>
<MenuOption onSelect={() => alert(`Not called`)} disabled={true} text='Disabled' />
</MenuOptions>
Changing your onPress
to onSelect
should start working as per your requirements.