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

Creating a StorageMethods file for asynchronous saving

Right now, any refresh or exiting of the application will wipe our list of tasks clean. That doesn't make for a very useful app, so we're now going to modify our actions to store and retrieve our list of tasks from AsyncStorage.

Let's create a utils folder within app, and then create a file titled storageMethods.js within utils:

This file will contain two functions:

  • getAsyncStorage: This gets the listOfTasks item in AsyncStorage and returns it
  • saveAsyncStorage: This accepts an array and saves it into AsyncStorage under the listOfTasks key

If you worked on the previous projects in this ...

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