Reputation: 78
static navigationOptions = ({navigation}) => {
return {
headerLeft: (
<View style ={{padding:10}}>
<Ionicons name = "md-menu" size={32} onPress ={()=>{navigation.navigate('DrawerOpen')}}/>
</View>
)
}
}
Upvotes: 0
Views: 1765
Reputation: 535
This solved the issue of navigation for me.
Install NativeBase by running npm install --save native-base
Run react-native link
to link the fonts
Import this import {Header, Left, Icon} from 'native-base'
The add this code to render(){}
render() {
return (
<View>
<Header>
<Left>
<Icon name="menu" style={{ color: 'white'}}
onPress={() => this.props.navigation.toggleDrawer()} />
</Left>
</Header>
<View>
<Text>Home Contents</Text>
</View>
</View>
);
}
Upvotes: 0
Reputation: 1590
As by React Navigation(v2). you may find the documentation here https://reactnavigation.org/docs/en/drawer-based-navigation.html
you need to use like this below
static navigationOptions = ({ navigation }) => ({
headerLeft: <Button onPress={() => navigation.toggleDrawer()} />
})
To open and close drawer, use the following helpers to open and close the drawer:
this.props.navigation.openDrawer();
this.props.navigation.closeDrawer();
If you would like to toggle the drawer you call the following:
this.props.navigation.toggleDrawer();
Each of these functions, behind the scenes, are simply dispatching actions:
this.props.navigation.dispatch(DrawerActions.openDrawer());
this.props.navigation.dispatch(DrawerActions.closeDrawer());
this.props.navigation.dispatch(DrawerActions.toggleDrawer());
Upvotes: 3