React-native-navigation: Toggle drawer by a tab bar button

Created on 20 Dec 2018  路  4Comments  路  Source: wix/react-native-navigation

Toggle drawer by tab bar button press with an anonymous inline function

I'm having a hard time to know what to do to make this work! I tried to pass props but I could't make it work. I tried to use static methods on the drawer class, yet, failed. I can use any help, and a good solution, thanks.
Here are the relevant codes:

export const MyCustomTab = createBottomTabNavigator(
{
  profile: ProfilePage,
  menu: {
    screen: () => null,
    navigationOptions: () => ({
        tabBarOptions: {
        showLabel: false
      },
    tabBarIcon: (
        <TouchableOpacity onPress = {() => [TOGGLE HERE]}> 
           <Image style = {MainStyles.TabbarMenuIcon} source={require('./resources/Icons/tab_bar_menu.png')}></Image>
        </TouchableOpacity>
      ),
        tabBarOnPress: () => {[TOGGLE HERE]}
    })
    },
},

const MyCustomDrawer = createDrawerNavigator(
  {
    Main: {
      screen: MainScreen
    },
    Setting: {
      screen: SettingScreen
    }
}
class MainScreen extends React.Component {
  constructor(props) {
    super(props);
  }

  static navigationOptions = {
    drawerLabel:  'main screen',
  };

  render() {
    return (
      <MyCustomTab/>
    );
  }
}

What should I type instead of [TOGGLE HERE] to access the drawer props navigation and toggle it? (We are in myCustomTab)

Just a quick note, the tab bar 'menu' button directs to nothing, no screen, I'm using it only as a button to open the drawer, which I'm having problems making it work!


Environment

  • React Native Navigation version: 2
  • React Native version: 0.57.4
  • Platform(s) (iOS, Android, or both?): BOTH
  • Device info (Simulator/Device? OS version? Debug/Release?): simulator android 8

Most helpful comment

@ketimaBU holy moly you're right! geez! Thank you! I post the question there!

All 4 comments

This will be possible when https://github.com/wix/react-native-navigation/issues/2766 is resolved.

@guyca the disabling buttons or adding onClick supports? I need neither of them right now. My problem is just how to pass the props in between these two navigations

@proxyjan the createBottomTabNavigatoris part of react-navigation and not react-native-navigation, I think you should post the issue in the right repo react-navigation.

@ketimaBU holy moly you're right! geez! Thank you! I post the question there!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

viper4595 picture viper4595  路  3Comments

swingywc picture swingywc  路  3Comments

nbolender picture nbolender  路  3Comments

zhanguangao picture zhanguangao  路  3Comments

bdrobinson picture bdrobinson  路  3Comments