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

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'; ...

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