Rendering icons
In the final section of this chapter, you’ll learn how to render icons in React Native components. Using icons to indicate meaning makes web applications more usable. So, why should native mobile applications be any different?
We’ll use the @expo/vector-icons
package to pull various vector font packages into your React Native app. This package is already part of the Expo project that we’re using as the base of the app, and now, you can import Icon
components and render them. Let’s implement an example that renders several FontAwesome icons based on a selected icon category:
export default function RenderingIcons() {
const [selected, setSelected] = useState<IconsType>("web_app_icons");
const [listSource, setListSource] = useState<IconName[]>([]);
const categories = Object.keys(iconNames);
function updateListSource(selected: IconsType) {
const listSource = iconNames[selected] as any;
setListSource...