O'Reilly logo

React Native By Example by Richard Kho

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Icon methods

The iconMethods file will be a lot simpler than our previous helper methods. With iconMethods, our goal is to keep an object that maps category names and icons and then, export a function that will help us return the react-native-vector-icon components.

import React from 'react'; import Icon from 'react-native-vector-icons/FontAwesome'; const expenses = [   { amount: '4', category: 'coffee', description: 'Latte' },   { amount: '1.50', category: 'books', description: 'Sunday Paper' },   { amount: '35', category: 'car', description: 'Gas' },   { amount: '60', category: 'restaurant', description: 'Steak dinner' } ];  

The categories object lets us quickly access both the category and icon name:

 export const getIconComponent = (categoryName, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required