Can't use react-native-vector-icons inside <Left></Left>
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
Do the Icons work outside of native-base components?
Yes
Just curious to know, why are you not using the fontawesome icons bundled with nativebase?
-
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. -
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.
-
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.
-
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.
@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.
@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.
@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.
@ericvan76 Yes it does. Thank you for providing right information. closing this issue!