LittleFunny
LittleFunny

Reputation: 8375

React Native: Using react-native-elements Icon return Can't find variable 'React'

I am following the code creating a CreateBottomTabNavigation with the use of react-native-elements to set up the icons.

const AppStack = createBottomTabNavigator(
{ 
    QrCode: { screen: QrCodeScreen },
    Profile: { screen: ProfileScreen }
}, 
{
    navigationOptions: ({navigation}) => ({ 
        tabBarIcon: ({focused, horizontal, tinitColor}) => {
            const { routeName } = navigation.state;
            let iconName;

            if (routeName == 'QrCode') {
                iconName = 'qrcode-scan';
            } else if (routeName == 'Profile') {
                iconName = 'face';
            }

            if (!focused)
                return <Icon type='ionicon' name={iconName} color='#517fa4'/>
            else
                return <Icon type='ionicon' reverse name={iconName} color='#517fa4'/>

            // You can return any component that you like here! We usually use an
            // icon component from react-native-vector-icons

        }
    }),
    tabBarOptions: {
        activeTintColor: 'tomato',
        inactiveBackgroundColor: 'gray'
    }
});

It give me the error enter image description here

Is it something wrong with the package..

Upvotes: 1

Views: 2276

Answers (1)

pritesh
pritesh

Reputation: 2192

Simply import React in top of your file like

import React from 'react'; 

It should work.

Upvotes: 1

Related Questions