Current User
After implementing user registration and login to your, you need to retrieve the currently logged user data to perform different actions and requests. Since React Native uses AsyncStorage as the local storage, this data can be retrieved using Parse.currentAsync inside your app’s component.
To complete this tutorial, you will need:
Get the current user data fetching using Parse for a React Native App.
The method Parse.currentAsync can be used anywhere on your code, after properly configuring your app to use Parse and AsyncStorage. Its response will be your current user’s object (Parse.User) or null if there is no logged-in user currently.
This method is essential in situations where you don’t have access to your application state or your user data, making it possible to perform relevant Parse requests in any component of your app.
In our previous guides, Parse.currentAsync was already used for testing and inside the HelloUser component. Here is the complete component again:
In this case, the Parse.currentAsync method retrieves the username and updates the state variable that is rendered inside the component JSX.
At the end of this guide, you learned how to retrieve the current Parse user data from local storage on React Native. In the next guide, we will show you how to allow your user to reset his password.