Reputation: 23
I have StackNavigator
component with a custom header for DrawerNavigator
.
The custom header has a button that should toggle Drawer on press. I have added the action as provided in React Navigation docs but doesn't work.
A snack with issue can be found here
What am I doing wrong? Thank you.
Upvotes: 2
Views: 1189
Reputation: 591
You can import: import { DrawerActions } from 'react-navigation';
And then just use it inside Header:
const Header = (props) => {
return (
<View style={{marginTop: 25}}>
<Button
onPress={() => props.navigation.dispatch(DrawerActions.toggleDrawer())}
title="Toggle"
color="#841584" />
</View>)
}
Upvotes: 5