React-native-vector-icons: Getting light version with Icon.getImageSource

Created on 26 Sep 2018  路  5Comments  路  Source: oblador/react-native-vector-icons

Hey,

I'm using the Icon.getImageSource method to get icons for a couple of places in our application. I've recently switched over to using the FontAwesome pro version, and I'd like to use the light version throughout my entire application.

The Icon control has the option to change it to the light version by setting the light variable to true. However, I haven't found a way to achieve the same result using the Icon.getImageSource function. Is is possible to do this? Thanks!

Most helpful comment

Phew, got me worried there for a bit but there was no issue really 馃檪 The light icons are Pro-only which means changing:

import Icon, { FA5Style } from "react-native-vector-icons/FontAwesome5";
to
import Icon, { FA5Style } from "react-native-vector-icons/FontAwesome5Pro";

should work. There are separate modules for the different fonts due to different icons being available. It should have used the fallback instead of going to null exception but that fix is still in a PR.

Also documented here 馃槈

All 5 comments

Did you check and try the docs?

Hey, sorry my bad. I overlooked that part of the docs.

However, when I try and pass the "FA5Style.light" I get a null reference exception. Is this a seperate issue or am I doing something wrong?

Code snippet:
import Icon, { FA5Style } from "react-native-vector-icons/FontAwesome5";

await Icon.getImageSource("tachometer-alt", 24, COLORS.BLACK, FA5Style.light)

Using version 5.0, on android.

Phew, got me worried there for a bit but there was no issue really 馃檪 The light icons are Pro-only which means changing:

import Icon, { FA5Style } from "react-native-vector-icons/FontAwesome5";
to
import Icon, { FA5Style } from "react-native-vector-icons/FontAwesome5Pro";

should work. There are separate modules for the different fonts due to different icons being available. It should have used the fallback instead of going to null exception but that fix is still in a PR.

Also documented here 馃槈

Wow, I actually overlooked that. Sorry for bothering you with these preventable issues, I'll pay more attention in the future.

Thanks a lot for the help, everything is working correctly! Great library.

No problemos, everyone learns to check the manual at some point 馃槈

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rmilejcz picture rmilejcz  路  3Comments

mahdidavoodi7 picture mahdidavoodi7  路  3Comments

AbhayVarshney picture AbhayVarshney  路  3Comments

reactor123 picture reactor123  路  3Comments

tharrington picture tharrington  路  4Comments