1. 16
    Add Icons to a React Native App with React Native Vector Icons
    2m 23s

Add Icons to a React Native App with React Native Vector Icons

InstructorChris Achard

Share this video with your friends

Send Tweet

There are many high quality icon libraries, so we’ll use an npm vector icon library to display svg icons in our application. This also requires a link step, which changes the underlying iOS and Android projects by linking the library to the native code.

Royston Shufflebotham
~ 6 years ago

At least on Android, if you add the react-native-vector-icons package, you then need to 1) stop the bundler, 2) wipe android/app/build, 3) restart the bundler, and 4) completely re-deploy the application onto the target device. Without doing these, the Android app shows crossed-out boxes instead of the star icons. See also https://github.com/oblador/react-native-vector-icons/issues/483

William Pei Yuan
~ 6 years ago

Question on: const stars = [...Array(Math.ceil(rating))]

Is this mainly to generate an array with the rating ceiling value of undefined, as placeholders so that we know how many Icons to display? This is super clever, I really like it, it took me a few minutes to realize the logic.

Is there another way to do this?

Thanks, and great tutorial.

Best, Will

Chris Achardinstructor
~ 6 years ago

Will: Yep! exactly. I wanted an array of length N (one for each star or half star). I could have also done that with a regular for loop, or a couple of other ways; but using the array constructor is a one liner that does it, so I went with that.

Niklas
~ 5 years ago

There are so many problems now with linking and coco pods, that it's far easier to use Expo., Ill skip the Icons section, as the documentation appears incorrect, and causes several errors