Wipe AsyncStorage in react native
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>
Try using clear() function which erases all AsyncStorage
for all clients, libraries, etc
You can clear AsyncStorage easily without touching your source code. Using react native debugger; and in the devtools console type
$reactNative.AsyncStorage.clear();
or to call it in RN's normal debugger with clear()
you can put this in...
if (__DEV__) {
global.clear = () => {
AsyncStorage.clear().then(() => console.log('Cleared'))
}
}