What is the naming convention for keys of AsyncStorage in React Native?

1.1k views Asked by At

In the official AsyncStorage example: https://facebook.github.io/react-native/docs/signed-apk-android.html Every key value has a @myAppStore: prefix.

await AsyncStorage.setItem('@myAppStore:key', '{ "data": [...] }');

However, in Save sensitive data in React Native, it seems Android and iOS both have their sandboxes, so the data is (kind of) secured.

Does the @myAppStore: prefix define the scope (eg. like creating a new collection in NoSQL), or it just a naming convention?

1

There are 1 answers

0
Fapi On

As far as I understand the @something notation is nothing that actually does anything special to the content that you put into the storage. It rather is a nice naming convention that they use.

Having said this, I think you can use whatever you want there as keys, but I kept it there to make my code more readable and quickly see where I use the async storage.

I always use AsyncStorage.setItem(@key,data) not @name:key because whatever you put in there as a field is indeed already the "key". Or the value under which your data is stored.

To store user and temporary key seems to be okay while I would not store backend keys.