Home > front end >  react native how to add drawerIcon inside options
react native how to add drawerIcon inside options

Time:08-24

//Here is my code

<Drawer.Screen
        name="Home"
        component={StackNavigator}
        options={({route}) => {
          const routeName = getFocusedRouteNameFromRoute(route) ?? 'Billing';
          if (sideMenuDisabledScreens.includes(routeName))
            return {swipeEnabled: false};
        }}
      />

I am implementing drawer navigator in my application and i want to add icon for drawer item home.Inside options i have added route to disable drawer for particular screens.After adding the route disable code i am not able to mention icons for drawerIcon.Please help me to add icon for my drawer screen home

CodePudding user response:

i get your point, you can have both properties just like this

options={({route}) => {
          const routeName = getFocusedRouteNameFromRoute(route) ?? 'Billing';
          if (sideMenuDisabledScreens.includes(routeName))
            return {swipeEnabled: false};
        },
       {
        drawerIcon: // add your comp here,
        title:" THIS is possible",
       }
    }

Hope ite helps. feel free for doubts

CodePudding user response:

Add drawerIcon property like the following:

drawerIcon: ({ tintColor }) => (
  <Image
    source={require('./chats-icon.png')}
    style={[{ tintColor: tintColor }]}
  />
),
  • Related