元素类型无效:期望字符串(对于内置组件)与React-navigation的TabBartIcon一起出现问题

时间:2018-04-19 09:14:09

标签: react-native react-native-android react-navigation react-native-ios expo

enter image description here

当我们想要在反应导航中的标签导航器中包含Ionicons时,它会显示这个看起来很奇怪的错误,只要我们使用反应导航指南如何实现它。这是代码:

with open("/root/nix_bsd_mac_inventory-master/Unique.txt") as fp:
    for line in fp:
        line = line.rstrip()
        if line in ips:
            print('{}: Ip is Already Tried: '.format(line))
            continue  # Continue means it will skip to the next password
        passwords = ['password1', 'password2', 'password3']
        for password in passwords:
            f3 = open("/root/nix_bsd_mac_inventory-master/inventory.cfg",
                      "w")
            print "Processing Ip: " + line
            f3.write("[device42_access]" + "\n" +
                     "base_url = https://1.8.0.3" + "\n" +
                     "username = uname" + "\n" +
                     "secret = abcd" + "\n" +
                     "[discover]" + "\n" +
                     "cpu= true" + "\n" +
                     "hardware = true" + "\n" +
                     "memory = true" + "\n" +
                     "[access]" + "\n" +
                     "credentials = username:" + password + "\n"  # Fixed typo here
            f3.close()
            p = subprocess.Popen(["./d42_linux_autodisc_v620"],
                                 stdout=subprocess.PIPE)
            p1 = str(p.communicate())
            if '1 devices were successfully added/updated' in p1:
                print('Sucessfull Completed Ip: ' + line)
                f6 = open("/root/nix_bsd_mac_inventory-master/SucessfullIp.txt", "a")
                f6.write("\n" + line)
                f6.close()
                break  # If successful it breaks, so don't need an else
            print "Password %s Unsuccessfull" % password
        else:
            # This happens when there are no more passwords to attempt
            print "No passwords were successful"

我们正在使用react-navigation版本:1.0.0-beta.21

此代码有什么问题?我们如何解决此问题?

2 个答案:

答案 0 :(得分:2)

试试这段代码:

const TabsBar = TabNavigator(
  {

   Home: {screen: HomeScreen},
   Profile: {screen: ProfileScreen},

  },

      {
    navigationOptions: ({ navigation }) => ({
      tabBarIcon: ({ focused, tintColor }) => {
        const { routeName } = navigation.state;
        let iconName;
        if (routeName === 'Home') {
          iconName = `ios-information-circle${focused ? '' : '-outline'}`;
        } else if (routeName === 'Profile') {
          iconName = `ios-options${focused ? '' : '-outline'}`;
        }

        // You can return any component that you like here! We usually use an
        // icon component from react-native-vector-icons
        return <Ionicons name={iconName} size={25} color={tintColor} />;
      },
    }),
    tabBarOptions: {
       activeTintColor: '#222222',
      inactiveTintColor: '#222222',
    },
     tabBarComponent: TabBarBottom,
    tabBarPosition: 'bottom',
    animationEnabled: false,
    swipeEnabled: false,
    initialRouteName: 'Home'
  }
);

答案 1 :(得分:1)

你错误地导入了它。将导入更改为import Icon from 'react-native-vector-icons/Ionicons';

以下