oblador / react-native-vector-icons

Customizable Icons for React Native with support for image source and full styling.
https://oblador.github.io/react-native-vector-icons/
MIT License
17.45k stars 2.12k forks source link

Element type is invalid... #563

Closed chocobuckle closed 7 years ago

chocobuckle commented 7 years ago

Spent the past 2 hours trying to debug this but can't figure out the problem. Any help would be much appreciated. I'm getting the following error: "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of FooterTabs."

import React from 'react';
import { Text, TabBarIOS } from 'react-native';
import { colors } from '~/styles';
import Icon from 'react-native-vector-icons/Ionicons';

export default function FooterTabs(props) {
  return (
    <TabBarIOS tintColor={colors.active}>
      <Icon.TabBarItem
        iconSize={35}
        iconName='ios-home-outline'
        title='Home'
        selected={props.activeFooterTab === 'home'}
        onPress={() => props.onTabSelect('home')}>
        <Text>HOME!</Text>
      </Icon.TabBarItem>
    </TabBarIOS>
  );
}
oblador commented 7 years ago

You need to use Icon.TabBarItemIOS instead of Icon.TabBarItem

chocobuckle commented 7 years ago

Thanks for the quick reply, but I've tried both and I'm still getting the same error. Btw, your examples use 'Icon.TabBarItem'...

capture

oblador commented 7 years ago

Right, yeah it seems there's backwards support for the old Icon.TabBarItem usage too. I'm kinda curious on your ~/styles import, are you targeting web or native?

chocobuckle commented 7 years ago

I'm targeting native. That's 'babel-plugin-root-import' I'm using for the styles import... https://github.com/entwicklerstube/babel-plugin-root-import

chocobuckle commented 7 years ago

I'm gonna close this as I suspect it's just something I'm overlooking rather than a bug - some fresh eyes and strong coffee the next morning usually solve all my problems! :)

Zyckzto commented 6 years ago

How did you fix it @chocobuckle ? this issue has been reopened #593

crock commented 6 years ago

Can someone post the solution. Perhaps @chocobuckle?

chocobuckle commented 6 years ago

Unfortunately, as far as I remember I never figured this one out guys. Apologies. I should have left the issue open, but I'd convinced myself the problem was some simple oversight on my end, so I closed it in the meantime. I would reopen it but since the other issue is the more recent one I think it's best to keep discussion there.

larissachen13 commented 6 years ago

@oblador This is still an issue. I am getting the exact same error but have followed all steps to install icons and followed the tab bar examples.

larissachen13 commented 6 years ago
screen shot 2018-02-09 at 5 18 06 pm