From f23ba70ad75564c21d2f40450a8a02ed07aed05c Mon Sep 17 00:00:00 2001 From: alex clifton Date: Fri, 22 Mar 2019 14:13:05 -0400 Subject: [PATCH] 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() --- .../examples/NavigationPlayground/app/SwitchWithStacks.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react-navigation/examples/NavigationPlayground/app/SwitchWithStacks.tsx b/packages/react-navigation/examples/NavigationPlayground/app/SwitchWithStacks.tsx index 562292d2..475c67e8 100644 --- a/packages/react-navigation/examples/NavigationPlayground/app/SwitchWithStacks.tsx +++ b/packages/react-navigation/examples/NavigationPlayground/app/SwitchWithStacks.tsx @@ -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 { }; 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 { } signOutAsync = async () => { - await AsyncStorage.clear(); + Platform.OS === 'ios' ? await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove) : await AsyncStorage.clear() this.props.navigation.navigate('Auth'); }; }