NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Can't use react-native-vector-icons inside <Left></Left>

Open veubit opened this issue 9 years ago • 8 comments

I only use native-base for some component do not entirely want to depend on this library. This time I was trying to use ListItem but got stuck into this problem.

react-native, react and native-base version

react-native: 0.40 react: 15.4.2 native-base: 2.0.0

Expected behaviour

I should be able to use react-native-vector-icons.

Actual behaviour

Currently it only works with inbuilt Icon of native base.

Steps to reproduce (code snippet or screenshot)

import { FontAwesome } from 'react-native-vector-icons/FontAwesome';

<ListItem>
          <Left>
            <FontAwesome name="user" size={22} />
          </Left>
          <Body>
            <Text>{contact_number}</Text>
          </Body>
</ListItem>

Above code doesn't work, but following code works

import { Icon } from 'native-base';

<ListItem>
          <Left>
            <Icon name="person" size={22} />
          </Left>
          <Body>
            <Text>{contact_number}</Text>
          </Body>
</ListItem>

Is the bug present in both ios and android or in any one of them?

Yes

veubit avatar Mar 06 '17 21:03 veubit

Do the Icons work outside of native-base components?

amelzer avatar Mar 07 '17 14:03 amelzer

Yes

veubit avatar Mar 07 '17 23:03 veubit

Just curious to know, why are you not using the fontawesome icons bundled with nativebase?

sankhadeeproy007 avatar Mar 08 '17 08:03 sankhadeeproy007

  1. Not all vector Icons are available check this list https://exponent.github.io/vector-icons/. I am trying to use Entypo icons 'fingerprint' & 'water' but its not working inside native base component.

  2. I am used to using vector-icons directly which are pretty straight forward, you just have to import provide name, size and color that's it.

  3. Didn't like the approach of native-base in this aspect. In case of icons too I have to provide size and color under style prop. Which is changing complete set of rules that you read in actual vector icons documentation. Writing wrapper around a library is a good practice but only if it is required.

  4. Why am I being forced to use trivial <Icon> component when I just wanted to use <ListItem>. Each native-base component itself should be pretty flexible & adoptable like bootstrap.

veubit avatar Mar 08 '17 11:03 veubit

@vexsnare, There is no icon called "person" in FontAwesome, and native-base's default icon family is Ionicons, that's where "person" came from. You can change the icon family via themes if you want to use any icons from FontAwesome.

ejfn avatar Mar 14 '17 10:03 ejfn

@ericvan76 Is there a way I can import and use one from FontAwesome & another from Ionicons within a component, as I can do with react-native-vector-icons.

veubit avatar Mar 14 '17 11:03 veubit

@vexsnare, like what I said, you can connect with different theme, or use 'react-native-vector-icons' directly. you did nothing wrong in your original post, it's not working just because that icon name "person" doesn't exist in FontAwesome. For more details, please look at IconNB.js and react-native-vector-icons.

ejfn avatar Mar 14 '17 12:03 ejfn

@ericvan76 Yes it does. Thank you for providing right information. closing this issue!

veubit avatar Mar 15 '17 07:03 veubit