Rendering icons
In the final section of this chapter, we'll look at rendering icons in React Native components. Using icons to indicate meaning makes web applications much more usable. So why should native mobile applications be any different?
You'll want to use the react-native-vector-icons
package to pull in various vector font packages into your React Native project. This is very straightforward to install:
npm install react-native-vector-icons --save react-native link
Now you can import the Icon
component and render them. Let's implement an example that renders several FontAwesome
icons based on a selected icon category:
import React, { Component } from 'react'; import { AppRegistry, View, Picker, ListView, Text, } from 'react-native'; import Icon from 'react-native-vector-icons/FontAwesome'; import { fromJS } from 'immutable'; import styles from './styles'; import iconNames from './icon-names...