Sign in Go Pro

Advanced React Native

Store Data to the Device with Async Storage

 
Autoplay

Up next

Previous

About

AsyncStorage is the easiest way to save data and load data in a React Native app.

We'll use AsyncStorage to save the user's username to the device, and then pull the username back when the app is re-loaded.

AsyncStorage is asynchronous, so we'll also protect against a flash of the Login screen, before the data is pulled back from the device storage.

Summary of Content:

  • Save the last username used to login to the device with Async Storage
  • Fetch the last username from Async Storage when the Login screen loads in componentDidMount
  • Use that last username to automatically log into the app
  • Remove the initial flash of the login page using local state to wait until the async storage callback is called.
  • Catch errors from async storage in case of failure

Resources:

https://facebook.github.io/react-native/docs/asyncstorage.html

Instructor

Links

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in Advanced React Native