Hack Facilito
Hack Facilito

Reputation: 71

Navigation('DrawerOpen') is not working

I am making an app following this tutorial:

I just did it exacly the same. It compiles but the button of the Drawer Menu does not work. This is the code where the button is:

    import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import {createBottomTabNavigator} from 'react-navigation';
import ScreenOne from './TabNavigator/ScreenOne';
import ScreenTwo from './TabNavigator/ScreenTwo';
import { Container, Header,Left,Right,Icon } from 'native-base';

export default class AppTabNavigator extends React.Component{

    static navigationOptions = ({navigation}) =>{
        return{
            headerLeft:(
                <View style={{padding:10}}>
                    <Icon name ="menu" style={{fontSize: 24, color : 'black'}} onPress={()=>navigation.navigate('DrawerOpen')} />
                </View>
            )
        }
    }
    render(){
        return(
            <HomeScreenTabNavigator screenProps={{navigation: this.props.navigation}}/>
        )
    }
}

const HomeScreenTabNavigator = new createBottomTabNavigator({
    ScreenOne:{
        screen: ScreenOne,
        navigationOptions:{
            tabBarLabel: 'Feed'
        }
    },
    ScreenTwo:{
        screen: ScreenTwo,
        navigationOptions:{
            tabBarLabel: 'Feed'     }
    }
})

Upvotes: 1

Views: 488

Answers (1)

Perry
Perry

Reputation: 11700

Since version 2.X of react-navigation you can't use the following code:

navigation.navigate('DrawerOpen')

But instead you need to use:

navigation.openDrawer()

See also the Drawer documentation

Upvotes: 1

Related Questions