React Native:使用react-native-elements图标返回找不到变量“ React”

时间:2018-10-17 21:53:15

标签: react-native navigation icons

我正在遵循使用react-native-elements设置图标来创建CreateBottomTabNavigation的代码。

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'
    }
});

它给我错误  enter image description here

包装是否有问题。

1 个答案:

答案 0 :(得分:0)

一样简单地将React导入文件顶部
import React from 'react'; 

应该可以。