Search code examples
react-nativelogoutasyncstorage

How to implement logout functionality in react native?


As i'm trying to develop an app in react native , i want to implement logout functionality.Now i found a problem that for every user who is logging, the name,and details appearing in their profile is same for each user.I'm using asyncstorage for setting unique id.Now i'm trying to unset this session using Asyncstorage.removeItem('key_uuid').Do i need to write this in a separate js file?I don't know actually where to give this code in my project.Sorry can anybody help me to figure this out?


Solution

  • It is simple implementation, on login you need to save some logged in user information as to check weather a user is logged in or not. You canprovide logout button anywhere in the app, and on clk of that you can clear your asyncStorage or remove only user info from storage. And when user opens your app you can check user in asyncstorage.