I save some items to AsyncStorage
in React Native and I am using chrome debugger and iOS simulator.
Without react native, using regular web development localStorage
, I was able to see the stored localStorage
items under Chrome Debugger > Resources > Local Storage
Any idea how can I view the React Native AsyncStorage
stored items?
On iOS, AsyncStorage is backed by native code that stores small values in a serialized dictionary and larger values in separate files. On Android, AsyncStorage will use either RocksDB or SQLite based on what is available.
React Native Debugger has this built in. Just call showAsyncStorageContentInDev() in the RND console and you'll be able to see a dump of your app's storage.
For store value in asyncstorage, React native asyncstorage provide setItem() method, it will expect storage key and value . Check below examples to store string, number, or object in AsyncStorage. To store number in AsyncStorage we have to first convert to string using toString() method.
React Native Debugger has this built in.
Just call showAsyncStorageContentInDev()
in the RND console and you'll be able to see a dump of your app's storage.
You can use reactotron i think it has Async Storage explorer ;) https://github.com/infinitered/reactotron
Following should work,
AsyncStorage.getAllKeys((err, keys) => {
AsyncStorage.multiGet(keys, (error, stores) => {
stores.map((result, i, store) => {
console.log({ [store[i][0]]: store[i][1] });
return true;
});
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With