unhandled promise rejection failed to delete storage directory (#5727)

with:

await AsyncStorage.clear();

I'm getting this in ios:

unhandled promise rejection failed to delete storage directory

found this:

https://stackoverflow.com/questions/46736268/react-native-asyncstorage-clear-is-failing-on-ios

switched to use this instead:

await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove)

but that causes unhandled promise rejection in android.

this is working:

Platform.OS === 'ios' ? await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove) : await AsyncStorage.clear()
This commit is contained in:
alex clifton
2019-03-22 14:13:05 -04:00
parent ec7e1f7f8a
commit f23ba70ad7

View File

@@ -5,6 +5,7 @@ import {
StatusBar,
StyleSheet,
View,
Platform,
} from 'react-native';
import { createStackNavigator, createSwitchNavigator } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
@@ -53,7 +54,7 @@ class HomeScreen extends React.Component<any, any> {
};
signOutAsync = async () => {
await AsyncStorage.clear();
Platform.OS === 'ios' ? await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove) : await AsyncStorage.clear()
this.props.navigation.navigate('Auth');
};
}
@@ -73,7 +74,7 @@ class OtherScreen extends React.Component<any, any> {
}
signOutAsync = async () => {
await AsyncStorage.clear();
Platform.OS === 'ios' ? await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove) : await AsyncStorage.clear()
this.props.navigation.navigate('Auth');
};
}