Jim
Jim

Reputation: 2312

How to add icons to drawer items using react-navigation?

None of the other questions/answers related to adding icons to drawer items have worked.

Goal: use an image component as the drawer item's icon

Problem: using answers supplied to other questions doesn't work. I get Reference Error: React is not Defined. The error is located at DrawerNavigatorItems at line {drawerIcon}

DrawerNavigator route config code:

const drawerRouteConfig = {
    Inbox: {
        screen: InboxStack,
        navigationOptions: {
            drawerIcon: () => (
                <Image
                    source={require('../assets/img/white-inbox.png')}
                    style={{ height: width * 0.05, width: width * 0.05 }}
                    resizeMode={'contain'}
                />
            )
        }
    },
    Discover: DiscoverStack,
    Account: AccountStack,

};

How do I properly implement drawerItem icons?

Upvotes: 0

Views: 323

Answers (1)

Jim
Jim

Reputation: 2312

My problem was that I hadn't imported React. fix: import React from 'react'

Upvotes: 1

Related Questions