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

Storage methods

The listOfExpenses we will store in our application will be a multi-layered object.

Visually, we will build it to look like this:

listOfExpenses = {   2017: {     01: {       budget: 500,       expenses: [         {           amount: '4',           category: 'Coffee',           date: 'Jan 12, 2017'           description: 'Latte @ Coffeeshop'         },         {           amount: '1.50',           category: 'Books',           date: 'Jan 17, 2017'           description: 'Sunday Newspaper'         }       ]     }   } } 

The methods we want to create for storage involve the following things:

  • getAsyncStorage: This retrieves the list of expenses in AsyncStorage
  • setAsyncStorage: This accepts an object and saves it into AsyncStorage as the list of expenses
  • checkCurrentMonth: This lets us accept a month and year as stringified numbers and finds out ...

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