The drawerNavigator is in the stackNavigator.
I set the header to none, and I want to make the header part work when I press the button.
I wrote the following code.
this.props.navigation.dispatch(DrawerActions.toggleDrawer());
No error occurs. But it does not do anything.
The navigator code looks like this:
navigator.js
const MainScene = createStackNavigator({
MainTab: {screen: MainTab},
OtherScene: {screen: OtherScene}
},{...})
const OtherScene: createStackNavigator({
DrawerScene: {screen: DrawerScene}
},{...})
const DrawerScene = createDrawerNavigator({
Page1: {screen: Page1},
Page2: {screen: Page2},
},{...})
Header.js
_sideMenu() {
this.props.navigation.dispatch(DrawerActions.toggleDrawer());
}
render() {
return (
...
<TouchableOpacity
onPress={() => this._sideMenu()}>
<Image ... />
</TouchableOpacity>
...
)
}
Both page1 and page2 contain directly written headers.
Page1.js
render() {
return(
<View>
<Header navigation={this.props.navigation} />
...
</View>
)
}
try this import { DrawerActions } from "react-navigation";
this.props.navigation.dispatch(DrawerActions.openDrawer());
this.props.navigation.dispatch(DrawerActions.closeDrawer());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With