AsyncStorage is the easiest way to save data and load data in a React Native app.
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