CurrentMonthExpenses example

The first thing I did was add and export a function called getMonthObject into storageMethods.js:

// Expenses/app/utils/storageMethods.js ... export const getMonthObject = async (month, year) => {   let response = await getAsyncStorage();    if (response[year] && response[year][month]) {     return response[year][month];   } } ... 

The getMonthObject method grabs the expenses object from AsyncStorage, checks for the existence of the year and month object, then returns it if possible. Here is how I used that method within the new currentMonthExpenses component:

// Expenses/app/components/CurrentMonthExpenses/index.js import React, { Component, PropTypes } from 'react';  import {   ListView,   Text,   View } from 'react-native'; ...

Get React Native By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.