Search code examples
javascriptreact-nativeasyncstorage

Asyncstorage React Native


How to mananged many id after i'm choosing diferrent id using asyncstorage ?

my problem is im currently using setitem to set my id and get that id in whole part of my apps but , i wanted to set and get diferrent id too , and remove that old id , any suggestion doing the best way to do that , thank you 😁😁


Solution

  • You can set different items with different keys.

    AsyncStorage.setItem('id','1234');
    AsyncStorage.setItem('id2','3334');
    

    If you want to use just one key:

    AsyncStorage.removeItem('id');
    

    You can remove an item just like that.