React Native Blueprints
上QQ阅读APP看书,第一时间看更新

Using vector icons

For this app, we will use two icons: a plus sign to add feeds and a trash bin to remove them. React Native doesn't include a list of icons to be used by default, so we will need to add one. In our case, since we are using native-base as our UI library, it's very convenient to use react-native-vector-icons, as it is supported natively from native-base, but it requires one extra configuration step:

react-native link

Some libraries use extra native capabilities which are not present in React Native. In the case of react-native-vector-icons, we need to include a number of vector icons stored in the library accessible natively. For these kinds of tasks, React Native includes react-native link, a script to automatically link the provided library to prepare all the native code and resources, which are needed for this library to be accessible within our app. Lots of libraries will require this extra step, but thanks to React Native's CLI, it is a very simple step, which in the past required moving files around projects and messing with configuration options.