I notice that I am wasting a certain amount of time debugging redux actions that I am persisting to AsyncStorage
in react-native thanks to redux-persist. Sometimes I'd just like to wipe AsyncStorage to save some development time and try with fresh data.
EDIT: Best case the solution should work on simulators and real devices, iOS and Android. Maybe there are different work arounds for different platforms.
Thanks
clear() Erases all AsyncStorage for all clients, libraries, etc. You probably don't want to call this; use removeItem or multiRemove to clear only your app's keys.
Just use AsyncStorage. removeItem('token'). It worked for me.
AsyncStorage is a simple, asynchronous, unencrypted by default module that allows you to persist data offline in React Native apps. The persistence of data is done in a key-value storage system. There are numerous scenarios where this module can be beneficial.
Try using clear() function which erases all AsyncStorage
for all clients, libraries, etc
clearAsyncStorage = async() => { AsyncStorage.clear(); }
This function can be applied anywhere on the code base to clear AsyncStorage
. For example, here is how it can be called on a <Button>
component.
<Button onPress={this.clearAsyncStorage}> <Text>Clear Async Storage</Text> </Button>
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